Starting at the command line

Although the linux is provided with number of  integrated GUI tools, still the best way to control the linux is command line interface. Command line tools have more options than the GUI tools. Theyv are even faster than GUI.

Presently we are considering the commands working on Bourne Again Shell(bash). Commands are capable of creating, editing, deleting, navigating to directories and files and almost any part of the system can controlled with the help of the commmand line.

Considering the various commands available are:-

* pwd
It stands for "present working directory" and it tells the absolute path of your current directory.
for example
# pwd
/etc/httpd/conf the output tells you are currently in the  /etc/httpd/conf

cd is used for change directory command.

moves up one directory level
moves up two directory level
cd /home/mj
navigates to the home directory of user mj
cd ~Navigates to your home directory. works for any user

Note:- Linux is case sensitive so remember all the small letters in commands represents the lower case letters.

ls is a versatile command which is used to list all the directories and files under your current directory. It can be used to find permissions, size of a file, check ownership, differentiate b/w file types.

lists in alphabetical order all the non-hidden files in current directory
         ls -a
list all the files including the hidden files
         ls -r
lists in reverse alphabetical order all non-hidden files in current directory
         ls -F
Lists all files by type. The character at the end of each file indicates the file type.
         ls -i
Lists the files by inode numbers. An inode number represents the location of the file on a volume.
         ls -l
Lists all the files in current directory, including the current directory(.) and the parent directory(..). Also lists the size, owner, and permissions associated with each file in what is known as long listing format.
         ls -t
lists the files by the last time they were changed
         ls -u
lists the files by the last time they were accessed

Path Management:-
While describing the location of a file, either specify the absolute path or relative path. An absolute path describes the location of a file relative to the root(/) directory. For example, following command get to the scripts that start a number of Linux daemons

# cd /etc/rc.d/init.d
forward slash in front makes it a absolute path. this command can be started from anywhere in the Linux to get to this directory.

absolute and  relative paths apply to the commands as well. eg:-
# ls /etc/rc.d/init.d

However if you use the relative path, your current directory matters. eg:- if the output from the pwd command is /home/mj, the following command won"t work unless you have an /home/mj/etc/rc.d/init.d directory:-

# ls /etc/rc.d/init.d


0 Responses to "Starting at the command line"

Post a Comment


Managing Shell And its Secrets

Subscribe To Get Update On Mobile

Get updates of latest post on your mobile free