In this section you will learn the Linux commands. To become Linux user or experts you will have to learn the Linux commands.
Most of the task in Linux have been accomplished by commands. Here i am presenting basic type of Linux commands.
Logging in to a Linux System
Start from the login screen.
Two types of login screens: virtual console (text-based) and graphical logins.
Login using login name and password.
Each user has a home directory for personal file storage.
What is root user and other user, will discuss in detail in next chapter.
Where will I write my command?
You can write your commands either in terminal or Virtual console.
How to open the terminal. Terminal works on X windows (graphical) system.
Application -->System Tools -->Terminal (as redline Arrow showing), in figure below.
This is defaults terminal screen.
Some important terms in Terminal.
indicates that you are logged as root.
shows your present home directory.
indicates that you are logged as normal user.
Linux Terminal for normal user
You will write any command after the #
Switching between virtual consoles and the graphical environment.
- A typical Linux system will run six virtual consoles and one graphical console Server
systems often have only virtual consoles. Desktops and workstations typically have both
Switch among virtual consoles by typing: Ctrl-Alt-F[1-6].
- Access the graphical console by typing Ctrl- Alt-F7.
The root user
The root user, a special administrative account also called the superuser root has near complete control
over the system.
- Do not login as root unless necessary Normal (unprivileged ) users' potential to do damage is more limited.
User switching Command
Description: This command is used to switch the user, In Linux you no need to logout to change the username, just type su username
then press enter key. If you are normal user, want to switch as root (superuser) then just type su
. as shown in figure below.
If want to change user root to mohit (normal user) use command.
[root@localhost ~]# su mohit
Next prompt would be
Now you will be thinking that there is no need of password because root user does not need any password to switch as normal user.
Simple Linux Commands
All commands should be written after [root@localhost ~]#
[root@localhost ~]# date
To display date and time
The date command also can be used to set the time and date. To set the time manually, do this:
[root@localhost ~] # date -s "21:46:00"
[root@localhost ~] # date -s "21:52:00 1 April, 2015"
See the figure below
Linux date command
If you want to display the calendar use command cal
as shown in figure.
Linux calendar command
if you specify the year after cal
command, it will display full calender.
Absolute and Relative Pathnames
Absolute path is begin with forward slash ( / ).
absolute path contains the root directory and all other subdirectories that contain a file or folder.
Relative path It is not begin with forward slash. The location of file or folder is relative to your current working directory.
A command has many options or switches written with command after - (hyphen)
Many levels of help
In Linux OS there are many type of help available for command learning.
The first is
[root@localhost ~]# whatis command
command display the short descriptions of commands.
Example shown below.
Linux whatis command
[root@localhost ~]# man command
command provides the manual page of command. The man
give the details specified command with its options.
When manual page is open you can press key q
to get back to terminal.
Linux Directory Commands
In Linux OS, there are variety of command are available in the context of directory operation.
To an absolute or relative path:
# cd cd /var/www/html
# cd www/html
Example shown below
Linux cd command
To a directory one level up:
[root@localhost ~] # cd ..
To your home directory:
[root@localhost ~] # cd
To your previous working directory:
[root@localhost ~] # cd -
To know current working directory:
[root@localhost ~] # pwd
See the example below
Linux directory command
Creating and Removing Directories in Linux
# mkdir /game
# rmdir /game
removes empty directories.
# rm -r
recursively removes directory trees
Listing Directory Contents
command lists the contents of the current directory or a specified directory.
ls [options] [dir]
Here i am presenting important options of ls
in order see all options of ls
page of ls
- -a (all) - Lists all files in the directory, including hidden files
- -l (long) - Lists details about contents, including permissions (modes), owner, group, size, creation date
- -r (reverse) - Lists the contents of the directory in reverse sort order.
- -R (recursive) -Lists the contents of all directories below the current directory recursively.
- -S (size) -Sorts files by their sizes
- -i for inodes
Linux directory command
Rest of command you see next page.