Monday, 16 July 2012

Basic Commands Part1


Command Option Description
1. Uname
uname -r
uname -n
To find the version of unix os
To find the machine name
2. Man
man grep
man -e grep
man -k copy
Print the user manual for any command.
To find the user manual for grep command.
One line definition of grep usage.
Helpful when we donot know which command will solve the purpose.e.g :- gives the different option available for copying.
cal 2009
cal dec
Print the calendar year or month
Print the calendar 2009 year
Print calender for current december month
4. Date
date +%m
date +%h
date +'%h%m'
date +%d
date +%y
H,M and S
Tue Mar 09 07:10:10 IST 2009
who am I
who -H
who -u
Login details of all the users in system
Login details for only myself
Login details for all users with headers info
Login details for only active users
To change the password
lock -45
lock the terminal for 45 minutes
To use the calculator
ls -x
ls -F
ls -a
ls -r
ls -x abc
ls -R
ls -ld
ls -il testfile
ls -lt
ls -ltr
ls -lut
To Print the contents of current directory.
Prints Multi column output of files with their names.
To Print only directoris and executable files.< * > indicate all files containing executable code and </> indicate the directories.
Print all files including hidden files. <a> stands for all.
Reverse the sort order of all the files with their names.
Print the content of abc directory.
Print all files and sub-directories in directory TREE.
Print all the directories.
Prints the inode number of file.
Prints all the file with their last modification time keeping latest modified at top.
Prints all the file with their last modification time in reverse order keeping last modified at bottom.
prints last access time of files.
cat testfile
cat > testfile
Print the content of any file.
Create a new file with testfile name.
cp -i testfile abc
cp -r abc newabc
To copy file and directories.
copying testfile to abc directory interactively.
copying entire directiry structure abc to newabc recursively.
rm -f newabc
rm -r newabc
All the options of cp command is applicable for rm command.
Removing directory newabc forcefuly.
Recursive deletion will not remove the write protected files.
Used for Printing the files
split testfile
split -72 testfile
split testfile newfile
To split the big files in different small files of 1000 lines each<default>.
Split the files into small files.
change the default split line size to 72.
Renaming the testfile to new name as <newfile>.
15. Cmp

These three command are used to find the difference in two files
wc -w testfile
wc -c testfile
wc -l testfile
wc testfile
Print the numbers of words, lines and character in the file
17.Path PATH=$PATH:/home/
Set the path variable for SHELL to use these directory path to locate the executables commands.
stty -a
stty intr \^c
stty eof \^a
Print current setting of terminal
To delete the character during backspacing
To change the interrupt key to Ctrl c instead of 'DELETE' default
To change the termination control of input during file creation using cat command from Ctrl d to Ctrl a.
alias l ='ls -ltr'
alias showdir ='cd $1;ls -l'
Print all the alias set in the system.
To create short hand names of command.
Passing positional parameter ETL to showdir alias will take us to that directory.
To redefine and unset the alias.
history -5
history 10 15
To find the previous command that has been used.
Print the last 5 command that has been used.
Every command has event number. Display event number between 10 an d15.
To change the defalult setting of command history saving feature.
21. r

r 20
Repeat previous command in Korn
Repeat previous command in Bash
Repeat previuos to prevoius command
Repeat the command with 20 event number.
Changes control to home directory
Changes absolute path home directory of user a_cmdb, the value of home directory can be seen by $HOME environment variable -
To switch between current working directory and most recently used directory.
chmod u+rwx newfile
chmod g+x newfile
chmod 757 newfile
chmod 457 newfile
chmod -R a+x abc
chmod -R 001 .
Changing the permission of file for user <u>, group <g>, others <o> or all <a> with + as assign , - as remove and = as absolute permission.r read<4>, w write<2> and x execute<1>.
Recursively changes the permission to execute for all directory and sub directory in abc directory for all users.
. Indicate the current directory.

No comments:

Post a Comment