Linux.com

Home Linux Community Forums Software Command Line Linux Tip : Linux Basic Commands

Linux Tip : Linux Basic Commands

Link to this post 27 Aug 10

[COLOR=#000000][LEFT][COLOR=#434343]For changing directory / to /etc
[B][root@pc1 /]# cd /etc[/B]
One step back /etc to /
[B][root@pc1 etc]# cd ..[/B]
Go to previous working directory
[B][root@pc1 /]# cd -
[/B]
Go to current login user home directory
[B][root@pc1 etc]# cd ~[/B]
Show the contents of /etc in single color
[B][root@pc1 ~]# dir /etc[/B]
Show the contents of /etc in different colors with nature of contents
[B][root@pc1 ~]# Ls /etc[/B]
create a folder on root partition
[B][root@pc1 ~]# mkdir /disk[/B]
Create a folder in /disk
[B][root@pc1 ~]# mkdir /disk/dir[/B]
Create multiple folder in multiple directories with single command
[B][root@pc1 ~]# mkdir /etc/dir1 /var/dir2 /usr/dir3[/B]
Create multiple folder in same directory
[B][root@pc1 ~]# mkdir dir1 dir2 dir3[/B]
Copy a file in directory
[B][root@pc1 disk]# cp file dir[/B]
Copy a file from /disk/file and paste it in /disk/dir/
[B][root@pc1 disk]# cp /disk/file /disk/dir[/B]
Copy a directory with -r option
[B][root@pc1 disk]# cp -r dir dir2[/B]
Copy a file from /disk/file and paste it in /etc with myfile name
[B][root@pc1 disk]# cp /disk/file /etc/myfile[/B]
Remove a file
[B][root@pc1 disk]# rm file[/B]
Remove a file with forcefully option
[B][root@pc1 disk]# rm -f file[/B]
Remove a directory with out -r option and you face will an error
[B][root@pc1 disk]# rm dir[/B]
Remove a directory with -r option
[B][root@pc1 disk]# rm -r /disk[/B]
Remove a directory with forcefully option
[B][root@pc1 disk]# rm -rf dir[/B]
Move /etc/dir1 to /disk/ with different name
[B][root@pc1 disk]# mv /etc/dir1 /disk/mydir[/B]
Rename the folder name mydir to dir
[B][root@pc1 disk]# mv /disk/mydir /disk/dir[/B]
Rename the file name with myfile
[B][root@pc1 disk]# mv file myfile[/B]
Read a file page by page with less command
[B][root@pc1 disk]# less /etc/grub.conf[/B]
Read a file page by page with more command
[B][root@pc1 disk]# more /etc/qrub.conf[/B]
Read first ten lines of grub.conf
[B][root@pc1 disk]# head /etc/grub.conf[/B]
Read last ten lings of grub.conf
[B][root@pc1 disk]# tail /etc/grub.conf[/B]
Read first 12 lines with -n option
[B][root@pc1 disk]# head -n 12 /etc/grub.conf[/B]
Read last 11 lines with -n option
[B][root@pc1 disk]# tail -n 11 /etc/grub.conf[/B]
Copy the contents of /etc/grub.conf in /disk/file
[B][root@pc1 disk]# cat /etc/grub.conf > /disk/file[/B]
Append the contents /etc/mtab in /etc/file
[B][root@pc1 disk]# cat /etc/mtab >> /disk/file[/B]
Merging tow commands with pipe sign output of the first command is input of second command
[B][root@pc1 disk]# cat /etc/squid/squid.conf I more[/B]
Count the total lines of squid.conf
[B][root@pc1 disk]# cat /etc/squid/squid.conf I wc -L[/B]
Show only spool words in squid.conf
[B][root@pc1 disk]# cat /etc/squid/squid.conf I grep spool[/B]
Flush the contents of file
[B][root@pc1 disk]# cat /dev/null > /var/log/messages[/B]
Programming Tutorials
Linux Tip : Linux Basic Commands
[/COLOR][/LEFT][/COLOR]

Link to this post 01 Sep 10

Very direct simplified list of linux basic commands. As a suggestion, give a brief explanation of the options used with a command. Good job.

Who we are ?

The Linux Foundation is a non-profit consortium dedicated to the growth of Linux.

More About the foundation...

Frequent Questions

Join / Linux Training / Board