Skip to main content

Posts

Showing posts from July, 2018

Shell and bash

Shell and bash You hear the term shell, shell script etc. quite frequently in ubuntu world. So what is a shell? Shell is a command interpreter. It accepts commands from user and interacts with the kernel of the operating system and gives you the output.  A shell can be either a text shell or a graphical shell. All of us use the graphical shell - which lets us create, copy, delete files and many other operations. A graphical shell is easier to use. A text shell or a CLI (command line interface) is a text based command interpreter. When we talk about shell, normally we mean this text based CLI. Linux systems have different shells available for the users. Bourne shell, C shell, bash etc. are the more common ones.  bash - (bourne again shell) is a shell we use very often in Ubuntu systems. To know available shells in your system, just cat /etc/shells We have earlier seen that to start a terminal or a shell we need to press CTRL+ALT+T command. This opens a new

File Commands

Redirecting output and piping Before we see file commands, let us see two operations which are quite useful. These are redirecting output (and input) and piping the output. We know that ls command lists the files in current directory. Can we save this listing to a file? Yes. That can be done using > - redirection operator. ls>a.txt redirects the output of ls command to a file called a.txt. Remember that is exactly how we created our file earlier - by redirecting output of cat command to a file. So what we see in screen shot is - output of echo command is redirected to cc.txt. And of course cc.txt has complete path information of our system. Next we pipe the output of echo $PATH  command to cat, so that it gets displayed. Piping is done using "|". It sends the output of a command as input to another command. So output of echo command is sent as input to cat. In the next line we are piping output of echo command to wc command. wc is word count c

User commands in Ubuntu

Echo command echo command is not exactly related to users. But it just echoes whatever you type. So if you say echo hello - it will display that The first echo line just displays hello.  The second echo command displays my home directory. $HOME is an environment variable which stores current user's home directory. The third echo command displays another environment variable $PATH . PATH indicates path of executable files. Whenever you type some command, the executable file with this command name is searched in the directories given by PATH variable. If the command is not found in any of the paths specified, then we get an error message - command not found.  Now let us put these commands together in a text file and try to run the file. To create a file, we can use vi editor or GUI editor called gedit. Since I am running a web terminal in a windows system, I do not have access to GUI editor.  I use cat command instead. Cat command it displays the content

File permissions

Let us go back to ls command covered in a previous post . ls command displays the list of files/sub-directories in current directory. And we also know that ls -a lists all files including the hidden files. Another commonly used option of ls is ls -l (long list) which gives us file name, its size, its date and time of creation, its owner, group and permissions. So what are these? So we see that long listing ls gives us lot of information. 3rd column tells us the name of owner (called user) of the file. - You are the owner of all files created by you. 4th column tells us the group the user belongs to. (Your admin might have put you in students group ) And 5th column tells us size of files - in bytes. 6th column is date and time of last modification of file. What are first and second columns in the list? 2nd column is number of links to the file. We talk about links later. 1st column is permissions of the file - who can read the file, who can write/modify file and who

Directories and files

In this blog, we will try to understand some of the useful commands in Ubuntu operating system.( or any other linux system). All the commands we discuss are terminal command. Because if we just wanted to work on GUI, we would have stayed back in Windows. Right. To start a terminal on your screen, give CTRL+ALT+t Starting and stopping Ubuntu system We know how to start the computer and login. But how do we stop the system? There are 3 text based commands for this operation viz halt, shutdown and reboot. halt    - will shutdown the computer reboot - will shutdown the computer and restart shutdown - has many options     shutdown -h now will shutdown     shutdown -r now   will restart     shutdown   +10  "shutting down the system in 10" will display the message given and shutdown the system after 10 minutes  Directories and files Directory - is nothing but a folder in windows terminology. It is a place where you store your files. And it has a name.