Important Commands Every Linux Beginners Should Learn

      Comments Off on Important Commands Every Linux Beginners Should Learn

Linux beginners would always ask how to operate linux in terminal. Here you can see some useful commands to getting started with Linux.

Important commands linux users should learn:

Hostname [hostname] :
=> It will show the hostname of our system
Eg: [email protected]:~$ hostname

How to change hostname:

 [email protected]:~$ hostname
 [email protected]:~$ hostname myhost
 [email protected]:~$ hostname

How to avoid unable to resolve hostname error:

To make hostname permanent we should add new hostname in /etc/hosts file

 # vim /etc/hosts
 change your server name in line:2
 # /etc/init.d/networking restart

Redhat 7:

# hostnamectl set-hostname myhostname

Whoami command:
=> It will display current user.

 [email protected]:~$ whoami

=> who command used to see the total users login to the server with physical terminal TTY or PTS according to your OS.

 [email protected]:/home/admin# who
 dinesh tty7 2016-09-19 10:09 (:0)

Pwd command :
=> It is present working directory. It will display the present directory which we are in.

 [email protected]:~$ pwd
 $ -> indicates that we are not working as root
 ~ -> users home directory

Cd command :
=> change directory, which is used to change our currecnt working directory.
$ cd dirctorypath

 [email protected]:~$ pwd
 [email protected]:~$ cd /var/local/
 [email protected]:/var/local$ pwd

ls command:
=> List, this is used to list the files and directories inside one directory.

 [email protected]:/home$ ls
 admin dinesh

=> To view the files which are hidden,use “a”, brief uses are

# ls -l => long listing
# ls -a => list all files including hidden files and directory
# ls -lh => Size in human readable format
# ll => same long listing

mkdir command:
=> make directory, it is used to create a new directory.

 [email protected]:~$ mkdir devops
 [email protected]:~$ ls -l
 total 16
 drwxrwxr-x 2 admin admin 4096 Sep 19 23:00 devops

touch command:
=> This is used to create a file

 [email protected]:~$ touch dev
 [email protected]:~$ ls -l
 total 16
 -rw-rw-r-- 1 admin admin 0 Sep 19 23:18 dev
 drwxrwxr-x 2 admin admin 4096 Sep 19 23:00 devops

cat command:
=> This is concatenate, it is used to viewthe contents of a file. Also used to create or append contents to a file

 [email protected]:~$ cat > dev
 => give some input words
[email protected]:~$ cat dev
 => It will display what you gave.
[email protected]:~$ cat >> dev
 => used to append content in a dir

cp command:
=> copy command, it uses to copy file or directory from one location to other

For file, # cp [option] location1 location 2
For dirctory # cp [option] location1 location2

 For file # cp /etc/hosts /var/hosts.cp
 For directory # cp -r /home/admin /home/dinesh/copies/
 r -> recursive
 v -> verbose
 f -> force

mv command:
=> move command, which is used to move content from one location to other or rename the file.


mv [option] location1 location2

 # mv /var/www/test.txt /var/spool/test
 => it will move the file
# mv /var/www/test.txt /var/www/test
 => it will rename the file

rm(remove) command:
=> rm is used to remove files or directories from our Linux machine..

rm [option] path

 $ sudo rm filename
 $ sudo rm -r directory name

=> We should be careful when use this command especially when we are using as root. It can delete anything with force(-f).

vi editor:
=> this is an editor used to edit files in Linux, some other editor are vim, gedit, nano, Emacs and Lime text.

=> I will show you how to use vi/vim editor later.

Without knowing this basic commands you can never start Linux…

Sharing is caring!


I'm an IT professional having multiple years of experience in IT Infrastructure planning, System integrations, Project implementation, and delivery. DevOps Enthusiast skilled with broad ranges of technology adoption. Well versed with Cloud Computing and Application Service Offerings such as SaaS/PaaS/IaaS. Expert in aligning business goals, mission and process to architect innovative solutions and strategies.