Before
you turn over to the next chapter where you are going to meet a plethora of
commands, remember a few things that apply to all UNIX commands.
- All UNIX commands must always be entered in small case letters
- Between the command name and the options that may be available with the command there must always be a space or a tab, for example, ls –l. Here is the command whereas –l is the option and the two have been separated by space. The option is usually preceded by a minus (-) sign. The option available with a command are often known as switches
- Two or more options available with command can usually be combined, for example, the command ls –l –a is same as ls –la
- If you make a typing mistake, press backspace to erase characters Don’t try back using arrow keys and then attempt deleting using the del key
- To cancel the entire command before you press Enter, press ctrl+c Or del key
Basic Commands:
~]$ date #To see the date of the system.
~]$ date
+%d-%Y-%H-%M #To see particular date
format you always use date options
Date Command Output |
~]$ cal #To see the current month calendar.
Cal Command Output |
~]$ clear #To clear the screen
~]$ ls –l #List files, directories with their
properties
~]$ ls #To list files and directories
~]$ ls –a #To list all hidden files and
directories
~]$ ls –d #To list only directoriesls -l Command output |
~]$ pwd #Print working directory
pwd Command output |
~]$ who am
I #To see from which user you have
logged in
who am i command output |
~]$ who #To see all who is logged in yet
this point of time from which IP
~]$ w #More details about user
related info
who command output |
~]$ uptime #To
see the server up time, boot time, users and load
uptime Command Output |
~]$ uname –a #Verify Operating system version, kernel
version and architecture
uname -a Command Output |
~]$ touch
<File Name> #Create an empty
file / Multiple empty files yet a time
Options:
~]$ touch
–am #it will change a file
time to current time
~]$ touch
–r file1 –B 30 file2 #it will
create two files with 30 seconds time difference
~]$ cat
/dev/null > file #To empty
the data file
~]$ cat > <File
Name> #Create an single file
with texttouch Command Output |
In above example two files 'kumar' and 'ravi' where created because we have provided the space in between 'kumar' and 'ravi' file names.
~]$ rm –rf
<File / Directory Name> #Delete files and directories forcefully
~]$rmdir
<directory> #Delete directories only
~]$ mkdir
<Directory Name> #Create an empty directory / directories
~]$ mkdir
–p <directory/directory/directory> #to create parent directories
~]$ cat
<File Name> #View
content of file
cat Command to read the file content |
~]$ time #Calculate
response time of the activity / command
time Command Output |
~]$ hwclock #to
see detailed date and time with time zone
hwclock Command Output |
~]$ cp
<Source path> <Destination path>
#Copy the files from one path to another path
~]$cp –Rv
<source> <destination> #copy
directories from source to destination
Options:
-R, -r, #copy directories recursively
-v #verbose to see progress of
copy job
-p #preserve
-f #forcefully
-I #interactive: Ask before overwriting filecp -v Command Output |
Copying directory must use –R to copy directories
cp -Rv Command Output |
~]$ mv
<source> <destination> #Move
files/directories
~]$ mv <old name>
<new name> #Rename the file and directory
mv Command Output |
~]$ last #Check
who logged in and when logged in duration
last Command Output |
~]$ arch #to
know architecture
~]$ reboot
/ init 6 #Restart
server
~]$poweroff
/ init 0 #To shut down
the server
~]$ dmesg #Check boot
process logsdmesg Command Output |
~]$
nsloookup <Server Address> #check
dns resolution
~]$ dig <server address> #check dns resolution to debug
~]$ tree
<directory> #it will
show the tree of parent directory
~]$ stat <file name> #detailed information about filestat Command Output |
~]$ wc #word count,
character count and line count
Options:
-l #Check line count
-c #Character Count
-w #Word Countwc Command Output |
Help relate commands:
~]$ whatis <Command
Name> #It will display single line
description about command
whatis Command Usage |
~]$ whereis <Command Name> #It will provide you
path of the command
whereis Command Output |
~]$ man
<command> #manual page of the
command
~]$ info
<command> #information
about the command
~]$
<command> --help #it will
gives a command options and there usage
~]$ apropos <keyword> #to know about the command useapropos Command Output |
hi,sir
ReplyDeletehow are you ? your blog aswom and i am very intersted
Thank you
ReplyDeletehelpfull documents
ReplyDelete