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.
Basic Commands:
~]$ cal #To see the current month calendar.
~]$ cal 11 2014 #To display the calendar, Month
November (11) and year 2014
cal
May 2016
Su Mo Tu We Th Fr Sa
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31
~]$ cd <Path of the directory> #Change directory
Options:
- 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
~]$ cal #To see the current month calendar.
cal
May 2016
Su Mo Tu We Th Fr Sa
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31
~]$ 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 directories
~]$ pwd #Print working directory
~]$ who am
I #To see from which user you have
logged in
~]$ who #To see all who is logged in yet
this point of time from which IP
~]$ w #More details about user
related info
~]$ uptime #To
see the server up time, boot time, users and load
~]$ uname –a #Verify Operating system version, kernel
version and architecture
~]$ 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 text
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
~]$ time #Calculate
response time of the activity / command
~]$ hwclock #to
see detailed date and time with time zone
~]$ 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 file
Copying directory must use –R to copy directories
~]$ mv
<source> <destination> #Move
files/directories
~]$ mv <old name>
<new name> #Rename the file and directory
~]$ last #Check
who logged in and when logged in duration
~]$ arch #to
know architecture
~]$ reboot
/ init 6 #Restart
server
~]$poweroff
/ init 0 #To shut down
the server
~]$ dmesg #Check boot
process logs
~]$
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 file
~]$ wc #word count,
character count and line count
Options:
-l #Check line count
-c #Character Count
-w #Word Count
Help relate commands:
~]$ whatis <Command
Name> #It will display single line
description about command
~]$ whereis <Command Name> #It will provide you
path of the command
~]$ 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 use
No comments:
Post a Comment