Basic Linux Command for Beginners

terminalThe shell command are used for administration of the Linux/UNIX Operating System. Most Linux command works with all the different Linux flavors for ex: Red Hat, Ubuntu, Linux mint, SUSE Linux, etc.. To use these command Terminal will be available.

1.  To check The running core process of the system

# ps

PID TTY TIME CMD

2953 pts/1 00:00:00 su

2962 pts/1 00:00:00 bash

2974 pts/1 00:00:00 ps

2.  To list the directory

#ls

file1 file2 file3 file4 file5 folder1 folder2 folder3 folder4 folder5

3.  To long list (it list with file type and permissions)

# ll

drwxr-xr-x 7 root root 4096 2012-06-03 04:10 ./

drwxr-xr-x 3 oxidizer oxidizer 4096 2012-06-03 04:05 ../

-rw-r–r– 1 root root 0 2012-06-03 04:10 file1

-rw-r–r– 1 root root 0 2012-06-03 04:10 file2

-rw-r–r– 1 root root 0 2012-06-03 04:10 file3

-rw-r–r– 1 root root 0 2012-06-03 04:10 file4

-rw-r–r– 1 root root 0 2012-06-03 04:10 file5

drwxr-xr-x 2 root root 4096 2012-06-03 04:10 folder1/

drwxr-xr-x 2 root root 4096 2012-06-03 04:10 folder2/

drwxr-xr-x 2 root root 4096 2012-06-03 04:10 folder3/

drwxr-xr-x 2 root root 4096 2012-06-03 04:10 folder4/

drwxr-xr-x 2 root root 4096 2012-06-03 04:10 folder5/

Note : This command only work in Linux Flavors not UNIX

4.  To Clear the present view Terminal

# clear

5. To clear total content of the terminal

#reset

6.  To switch the present user to another user

#su username

7.  To switch to Supper user

#su

password : *****

8.  Creating a regular file

#touch filename

9.  Creating Directory (folder)

#mkdir foldername

Note : ‘mkdir’ is represent Make Directory

10.  Getting into a directory

#cd foldername

Note : ‘cd’ represent change directory

11.  Rename the directory or file

#mv filename1 filename2

Note : After ‘mv ‘ the filename1 is the file needed to be renamed and after a space filename2 the new name to that file

12.  Deleting a regular file

#rm filename

13.  Deleting a directory (folder)

#rm -rf foldername

14.  To monitor running Process and hardware usage

# top

Tasks: 150 total, 3 running, 147 sleeping, 0 stopped, 0 zombie

Cpu(s): 1.7%us, 0.5%sy, 0.0%ni, 97.8%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st

Mem: 3060076k total, 1549500k used, 1510576k free, 149252k buffers

Swap: 5996540k total, 0k used, 5996540k free, 945596k cached

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND

1791 oxidizer 20 0 374m 102m 47m R 2 3.4 1:28.43 plasma-desktop

1782 oxidizer 20 0 309m 67m 33m S 1 2.2 1:13.51 kwin

1177 root 20 0 93280 33m 19m R 1 1.1 1:21.57 Xorg

1073 boinc 39 19 15708 4484 3408 S 0 0.1 0:03.20 boinc

1418 root 20 0 0 0 0 S 0 0.0 0:00.14 flush-8:0

1796 oxidizer 20 0 2744 1184 820 S 0 0.0 0:12.04 ksysguardd

2063 root 20 0 0 0 0 S 0 0.0 0:00.38 usb-storage

1 root 20 0 3644 2044 1352 S 0 0.1 0:01.01 init

2 root 20 0 0 0 0 S 0 0.0 0:00.00 kthreadd

3 root 20 0 0 0 0 S 0 0.0 0:00.66 ksoftirqd/0

6 root RT 0 0 0 0 S 0 0.0 0:00.00 migration/0

7 root RT 0 0 0 0 S 0 0.0 0:00.01 watchdog/0

8 root RT 0 0 0 0 S 0 0.0 0:00.00 migration/1

10 root 20 0 0 0 0 S 0 0.0 0:00.62 ksoftirqd/1

15.  To see at present which directory user working with and the path.

#pwd

/etc/firefox

Note : “pwd” is Print Working Directory it will show in terminal what is the path of working directory

16.  Copying file from one place to another place

#cp filename /home/sam/Documents/

Note : “cp” is copy then after a space give file name then after a space again give the full path when the file to be copied

17. To add a (insert) text into a file

#echo “this is the edu session” > filename

18.  To append (insert) text into a file.

#echo “this is the edu session” >> filename

19.  To hide a file

#mv filename .filename

Note : after “mv” the “filename” is the file name of which file you need to hide
the a space give same file name followed by dot ( . )

20. To read the file with out open

#cat filename

this is the text of Linux Terminals file

21. To list the all type files include hidden files

#ls -a

Note : It will show the list of all files in the current directory

21. To list only hidden files

#l.

Note : Placing(Dot) after the “l” it will show only the list of all hidden files in the current directory

22.  To long list

#ls -l

Note : This command only work in Linux Flavors not UNIX

23.  To list with the physical location of the data (Show with inode numbers)

#ls -i

24.  To combine all the information of the data

#ls -ali

25. To check the data size

#du filename

26.  To check the data in human readable format

#du -h filename

Note : 25 and 26 commands are can be used with folder or any data to check the size of it

27.  To get information about file

#stat filename

28.  To check the last command is executed well or not

#echo $?

Note : The result is ‘0’ then the last command was run well. If it shows ‘1’ or other it means the last command was not run

29.  To find a file

#find / -name ‘filename’

30. To check the memory

#free -m

31.  To create many files at a time

#touch filename{1..10}

32.  To run more then one command at one time

#cat filename ; date ; ls

3 thoughts on “Basic Linux Command for Beginners

  1. loans site says:

    The last time I stumbled across a site this interesting it cost me my girlfriend i’m sure, I spent so much time on it.

  2. Love the site, thanks 🙂

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: