[user@hostname <current dir>]<user> #/$$: This is the default user shell prompt. It appears when you are logged in as a regular user.
#: This is the root shell prompt. It appears when you are logged in as the superuser (root) or when you have escalated your privileges using sudo. The root prompt indicates that you have administrative privileges and can execute commands with elevated access.
example for regular user ubuntu@hostname:~$ and root userroot@hostname:~#
[root@server0 /]# whoDisplay current logged in all users with their details
[root@server0 /]# whoamiDisplay current user details.
[root@server0 /]# wDisplay current user username.
[root@server0 /]# wh <tab> <tab>To see similar commands or autocomplete cmd.
[root@server0 /]# clear or ctrl+lIt clears screen but not background data.
[root@server0 /]# calIt displays current month of calendar.
[root@server0 /]# cal 2016It displays specified year calendar.
[root@server0 /]# cal 07 2015It displays specific months calendar in particular year
[root@server0 /]# cal -3It displays previous, current and next month's calendar of current year.
[root@server0 /]# cal -j 2015It displays Julian days of particular year.
[root@server0 /]# dateIt shows current date and time.
[root@server0 /]# date -j <year> -s “DD MM YYYY HH:MM:SS It set date and time.
[root@server0 /]# reboot or init 6To restart the system
[root@server0 /]# poweroff or init 0To power off system.
[root@server0 /]# shutdown or shutdown -h 10It shutdown system after 10 min and broadcast message to all users.
[root@server0 /]# shutdown -cIt cancels shutdown timer and broadcast message to all users.
[root@server0 /]# logout or exit or ctrl + DLogout from currently logged in user.
[root@server0 /]# hostname or hostname -sShows machine name
[root@server0 /]# hostnamectl Show detailed information about system
[root@server0 /]# username -a It displays operating system kernel name.
[root@server0 /]# username -r It display all information regarding system
[root@server0 /]# free -hIt display RAM information in human readable form
[root@server0 /]# lsusbIt lists all available USB devices.
[root@server0 /]# lspciIt list all PCI devices
[root@server0 /]# lscpuIt list processor information.
[root@server0 /]# dmidecodeIt display all hardware information.(root)
[root@server0 /]# manShow manual of mentioned command
[root@server0 /]# infoSame as that of man command
[root@server0 /]# whatisDisplay one line description of manual page. (#mandb command should use to update database manuals.)
[root@server0 /]# <command> --helpShow short description of manual page. –help is option thus, some command may not support this option.
[root@server0 /]# which <CMD>To know path of command file.
[root@server0 /]# touch filename.txttouch command is used to create files. Using touch command, multiple files can be created.
- examples
[root@server0 /]# touch /root/file1.txt[root@server0 /]# touch /root/Desktop/file1.txt /etc/data.mp3[root@server0 /]# touch /root/{data.txt,file.txt,demo.mp3}[root@server0 /]# touch /root/file{1..100}.txt
[root@server0 /]# mkdir dir1mkdir command creates directories. Creating multiple directories are also possible using mkdir command
- examples
[root@server0 /]# mkdir /dir1[root@server0 /]# mkdir /dir1 /root/Desktop/dir2 /etc/demo[root@server0 /]# mkdir /root/{demo,data,practice}[root@server0 /]# mkdir /practical{1..10}[root@server0 /]# mkdir –p /demo/data/practice
[root@server0 /]# cat /root/anaconda-ks.cfgcat command is used to get data of file as output on the terminal. Reading out large file leads to navigate in terminal, which require separate scrolling device (mouse). So, cat command is very useful in reading smaller files with few lines of data in command line.
- examples
[root@server0 /]# cat /root/anaconda-ks.cfg
[root@server0 /]# more /root/anaconda-ks.cfgmore command provides line by line navigation and page by page navigation in downward direction but, upward scrolling not possible.
[root@server0 /]# less /root/anaconda-ks.cfgless command allow navigation keys for scrolling up and down. Thus, it is more useful command than any other four command.
[root@server0 /]# head /root/anaconda-ks.cfghead command show few lines from top of the file. If head command is used without any option, it will show top ten lines by default. –n is used to give count of lines to be shown.
[root@server0 /]# tail /root/anaconda-ks.cfgtail command show few lines from bottom of file. If tail command is used without any option, it will show bottom ten lines by default. –n is used to give count of lines to be shown.
[root@server0 /]# sort file1.txtSort command will display result in ascending or descending order. Without option, data will be shown in ascending order.
- examples
[root@server0 /]# sort –r file1.txt
[root@server0 /]# cp /root/anaconda-ks.cfg ~/Desktop/kickstart.txtCopy operation use to copy files and directories in Linux, from one location to another. It will copy contents of one file to another. If destination file is not exist in given location then automatically new file will be generated.
- examples
[root@server0 /]# cp /root/anaconda-ks.cfg ~/Desktop/kickstart.txt[root@server0 /]# cp /root/anaconda-ks.cfg /mnt/[root@server0 /]# cp -r /etc /root[root@server0 /]# cp –r /root/* /media[root@server0 /]# cp –rv /abc.txt/xyz.mp3/media
[root@server0 /]# mv /root/anaconda-ks.cfg /mnt/Move and rename both operation can be performed using ‘mv’ command. It moves files and directories from one location to another. It is possible to move and rename at the same time.
- example
[root@server0 /]# mv /root/anaconda-ks.cfg /mnt/[root@server0 /]# mv /media ~/Desktop/[root@server0 /]# mv /root/* /mnt/[root@server0 /]# mv fower flower.txt[root@server0 /]# mv /root/anaconda-ks.cfg /root/kickstart.cfg,[root@server0 /]# mv /opt /demo[root@server0 /]# mv /root/anaconda-ks.cfg ~/Desktop/kickstart.txt
[root@server0 /]# rmdir /Demormdir command only deletes empty directories.
[root@server0 /]# rm -vf /Demo/file1.txtrm command is use to delete files and directories.
- examples
rm /Demo/file10.txtrm -vf /Demo/file1.txtrm –f /Demo/*,rm –r /Demo