An Introduction to Linux Command Line Part-1
There are two types of user interfaces Graphical User Interfaces (GUI) and command line interface (CLI). In GUI you use mouse to give instructions, in command line you type commands to control your computer. Linux provides two ways of exploring command line, you can either start a terminal emulator or switch to virtual console.
Terminal emulator is a program that provides access to command line when you are in GUI. It opens up a window in which you can type commands. To start a Terminal Emulator look in the application menu.
To switch to virtual console press <Ctrl><Alt><F1> i.e. press and hold control key then press and hold Alt, now press F1 key. It will give you a log in prompt where you can type in your username and press enter. Now type your password to login. While typing the password you won’t see it on screen. You can type commands after logging in. There are six virtual consoles by default. To switch to second one press <Ctrl><Alt><F2> and so on. To switch back to GUI press <Ctrl><Alt><F7> .
Noramal users and root user
When you open up a terminal or login into virtual console it will show you something like
[username@hostname~]$ eg. My laptop shows [sumit@sumit-laptop ~]$.
The $ sign means that you are normal user, you only have limited powers. A root user has many more powers than a normal user, as a root user you change all the critical system settings. There are some commands that only a root user can run. To become a root user press enter after typing
su – [if you are using Slackware, Fedora or Red Hat based distribution.]
sudo -i [ if you are using Debian, Ubuntu].
It will ask for your root password please enter it and also it is important to note that while you
are typing the password it will not be displayed on the screen for security reasons press enter after your are done typing the password. For Ubuntu this password is same as your user password, Fedora and others asks you to set root password during installation.
After you become a root the prompt will look something like [root@hostnamename~]#.
Now you are root user. Since a root user can make critical changes and even delete important system files so be careful with what you type as a root user. Only login as root user when necessary.
Basic Linux Commands
In Linux the general syntax of any command is
command name [options] [arguments]
Options usually start with “–”
Example : In command ls -l /home, -l is option and /home is argument.
The things that are written in  brackets means that they are optional i.e. you may or may not use them its your choice but you may use them to modify the behavior of command according to your needs. If you don’t use them some defaults options and/or arguments will be used.
1. pwd (print working directory)
To find out where you are in file system tree i.e. current directory type
So by looking at the output we can say in am currently in /home/sumit directory.
2. ls – list directory contents
Now you know that you are currently in /home/sumit. Now you can type ls to list all the files and directories in /home/sumit directory.
ls command also acceps arguments and options like most of linux commands. Using ls with option -l i.e. Typing ls -l will give you more detailed output. If you type ls /home, the command will display all the files in /home folder. Here /home is taken as argument.
3. cd – change directory
You can you use cd to change you current directory (pwd). While using cd you can either specify relative path or absolute path. Relative path depends on your current directory (output of pwd command) i.e. their result depend upon your current location in file system tree, absolute paths always start from / and their result does not depend on your current directory. Ex – Let us say your current directory is /home/sumit and /home/sumit contains a folder named Documents. I can type “cd Documents” to go to Documents directory (relative path) or I can type /home/sumit/Documents. The former only works when my current directory is /home/sumit. If you type cd .. it will take you to the parent directory i.e. if you are in /home/sumit/ typing cd.. will take you to /home, now typing cd .. once more will take you one step higher to / directory.
4. mkdir – make directories
You can use mkdir command to create new directories, here you can use absolute or relative paths just like cd command.
[user@hostname ~]$ mkdir dirname (create a directory named mkdir in current directory)
[user@hostname ~]$ mkdir /home/sumit/test2 (creates directory /home/sumit/test2 using absolute path).
5.Using Tab auto completion
Use can use auto completion to save time when typing commands or filenames. If you are typing mkdir command, just type mkd and press tab it will auto complete the command, if it doesn’t press tab twice and it will list all the commands that has mkd as its first three characters. Simiraly you can type
ls /ho and press tab is will auto complete the command to ls /home.
All the commands you type and stored in history. You can move b/w history by using upper and downward arrow keys on your keyboard, and press enter to execute.
Although u can also type Command-”history” and you will see that the commands you types in the past with a number. Want to run the command directly without typing again type “!number” and the command on that number will get executed. Here’s the screenshot
Well thats it for now… Wanna know More abt the CLI Basics… Wait For Part-2