• cat filename1 > filename2 :
This overwrite contents of filename2 with filename1
• cat filename1 » filename2 :
This appends contents of filename1 to filename2.
• cd /usr:
Changes current directory to /usr directory
• cd .. :
Change current directory to previous higher directory.
• cd :
Change to home of current userid.
• chgrp group1 filename1 :
Change group id to group 1 for filename1.
• chgrp -R group1 * :
Changes group id of all files in current and subdirectories to group 1.
• chmod ugo+rwx filename1:
Add read/write/execute permission to filename1 for user/owner, group and others (world).
• chmod o x filename1 :
Remove execute from others (world)
• chmod 751 filename1 :
Set rwx for user/owner, group and others; r=4, w=2, x=1, rwx=7 rx=5, rw=6, wx=3, none=0.
• chown sam filename1 :
Change owner of file filename1 to sam.
• chown -R sam * :
Change owner to sam for all files in current and subdirectories.
• clear :
Clear the terminal screen.
• compress filename1 :
Compress file filename1 and replace it with filename1.Z
• cp filename1 filename2 :
Copy file filename1 to filename2 destroying the contents of filename2.
• cp -i * /usr/local/bin :
Copy all files in current directory to /usr/local/bin directory; Prompt before overwriting files (i)
• cpio :
Copy file archives to disk/tape
• crontab -e :
Edit crontab file for current user
• crontab -e bill :
Edit crontab file for user bill
• crontab -l :
List crontab entries for current userid
• csh :
Start the c shell process
• cut -d: -f1,5 /etc/passwd :
Extract the 1st and 5th fields (username & real name) from file /etc/passwd where delimiter is colon
• who | cut -d" " -f1:
List login names from who command
• date :
Display current date string
• date +%D :
Display current date, MM/DD/YY format
• dd :
Copy file(s) to/from raw devices
• df :
Displays free disk blocks and modes on file systems.
• df -k :
Displays free space in kilobytes for mounted file systems
• echo name :
Displays literal "name" on screen
• echo $PATH :
Displays PATH environment variable
• ed/edit/ex :
Alternative line editors, see vi
• env Displays current environment variables or allows setting
• file filename1 :
Determines and displays type of file for filename1 (text, data, executable, directory, symbolic link...etc...)
• find /usr/opt/bin -name "filename1*" -print :
Starts searching in /usr/opt/bin for files starting with
• filename1, If found prints the full file names and continues searching subdirectories
• find . -type f -print | xargs grep -i [PATTERN] :
Recursive grep for a pattern in a file (searches through files in subdirectories)
• find . ! -mtime - | /usr/bin/xargs rm -rf :
Finds and removes files older than specified
• finger sam :
Displays data about user session for sam
• ftp solar :
Establishes a File Transfer Protocol session over the network between current host and a host named solar; See man pages for additional ftp commands
• grep jdoe /etc/passwd :
Searches the file /etc/passwd searching for string "jdoe"; If found, displays
• grep -i Sam filename1:
Search filename1 for upper or lower case string of Sam and display lines found
• groups sam :
List groups that sam is a member of
• head filename1 :
Display first few lines of filename1
• head -50 filename1:
Display first fifty lines of filename1
• id :
List current user id and any group ids
• kill -9 1351 :
Terminate process number 1351
• ksh:
Start Korn Shell command interpreter; See man pages; Preferred shell for most users
• ln -s filename1 /usr/opt/filename2 :
Create a symbolic link named /usr/opt/filename2 that points to filename1; See man pages
• lp -d lp1 filename1 :
Print filename1 on destination printer lp1
• lpstat -d :
Displays name of default printer, if any
• lpstat -a :
Lists printers accepting print requests
• lpstat -s :
Displays most everything regarding printing
• lpstat -u sam :
Displays status of sam's print jobs
• ls -al :
Displays all files in wide listing
• ls -al *.doc :
Displays files ending with .doc
• ls -al /bin/k*:
Displays files starting with k in /bin directory
• man --is Online UNIX manual:
• man-pages:
It gives detailed instructions on all of the commands listed here and a lot more.See man man for more...
• mail sam :
Starts mail message to sam
• mailx sam :
Nicer looking mail utility
• mkdir -p /usr/opt/dirx:
Creates dirx below /usr/opt
• make:
Code compilation utility
• mkdir dirx:
Creates directory dirx
• more filename1 :
Displays single pages from filename1 pausing after each page.for many options see man pages
• mv filename1 /usr/opt/ :
Moves filename1 to directory /usr/opt; Unlike the cp (copy) command, mv removes file from origin
• netstat -i:
Show the TCP/IP network interfaces
• netstat -r:
Show network route table
• netstat -rn:
Displays routing information but bypasses hostname lookup
• netstat -a | more :
Show the state of all sockets
• newgrp group1 :
Changes current group to group 1
• news :
Displays unread files from /usr/news or /var/news
• nice/renice :
Adjusts process’ execution priority
• Unix Commands from p to z:
• passwd:
Allows changing your login password
• ps :
Lists all of current user's live processes
• ps -ef :
List all users processes that are executing
• pwd:
Displays current working directory you are in
• rcp filename1 hostb:
/usr/local/bin :
Copies filename1 from current host system to hostb, and places it in the /usr/local/bin directory; The .rhosts or hosts.equiv files must be setup to allow action
• rksh:
Starts restricted Korn Shell session
• rlogin hostb :
Logs into remote host name hostb
• rm filename1 :
Deletes filename1 from the disk without recourse
• rm -i filename1 :
Deletes filename1 after prompting for verification
• rmdir dirx :
Deletes directory dirx
• rmdir -r dirx:
Deletes directory and all contents
• rsh:
Restricted version of Bourne Shell for security
• sar :
System Activity Reporter
• sh :
Bourne Shell command interpreter; Alternative to Korn Shell and C shell but is the default on most systems; Older version that is losing popularity
• sleep 3 :
Pauses for 3 seconds and continues
• stty sane:
Attempts to restore terminal settings after they are hosed; Use CTRL-J with this command
• stty erase ^H :
Use to reset backspace/delete; ^H is the key you may want to use for backspace/delete;
• su sam:
Log on as user sam
• su - sam:
Log on as sam, and execute his profile too
• tail filename1 :
Display last few lines of filename1
• tail -50 filename1 :
Display last fifty lines of filename1
• tail -f :
Continually reads updating file; Great for monitoring a log file while being written
• tar -cvf /dev/rmt/0c /usr/bin/* :
Tape archive utility; Copies all files in /usr/bin directory to tape device /dev/rmt/
• tar -xvf /dev/rmt/0 /usr/bin/ :
Extracts all files from tape device /dev/rmt/0 and writes them to /usr/bin/
• tar -tvf /dev/rmt/0c :
Read tape on device /dev/rmt/0c and lists contents in verbose mode
• tee:
Used in scripts to split output to two outputs. Usually used with a pipe command (|)
• tee -a /tmp/filename1:
Append the output to filename1 without overwriting its original content
• telnet hostb:
Create a remote terminal on hostb
• touch filename1 :
Creates an empty file named filename1; Changes modification time to current time if the file already exists
• uname -a:
Lists 0/S revision, host name, hardware
• uncompress filename1 :
Uncompresses file with .Zsuffix, created by compress command previously
• uptime :
Displays current time, time logged-in,number of users etc
• users:
Displays current logged-in users in a listing
• uucp :
UNIX-to-UNIX copy utility; See man pages
• view filename1:
A read only version of vi editor
• w :
Combination of uptime, who and ps -a commands
• wall :
Write to all; Allows entry of message to be sent to line 25 of all terminals; End message with a CTRLD command
• wc -l filename1:
Utility that counts the number of lines in filename1
• wc -c filename1 :
Utility that counts the number of bytes in filename1; -m provides number of characters
• wc -w filename1 :
Utility that counts the number of the words in filename1
• whence filename2:
Prints path name location of executable filename2
• which filename2 :
Similar to whence command
• who Displays login name, terminal name, date, and time of login, of users currently logged in
• who am i :
Displays effective user id of user
• who -b :
Displays date/time of last reboot
• who -r :
Displays current system run level
1 List the files in current directory sorted by size ?
ls -l | grep ^- | sort -nr
2. List the hidden files in current directory ?
- ls -a1 | grep "^\."
3. Delete blank lines in a file ?
– cat sample.txt | grep -v ‘^$’ > new_sample.txt
4. Search for a sample string in particular files ?
grep .Debug. *.conf
Here grep uses the string .Debug. to search in all files with extension..conf. under current directory.
5. Display the last newly appending lines of a file during appending data to the same file by some processes ?
tail .f Debug.log
Here tail shows the newly appended data into Debug.log by some processes/user.
6. Display the Disk Usage of file sizes under each directory in currentDirectory ?
du -k * | sort .nr (or) du .k . | sort -nr
7. Change to a directory, which is having very long name ?
cd CDMA_3X_GEN*Here original directory name is . .CDMA_3X_GENERATION_DATA..
8. Display the all files recursively with path under current directory ?
find . -depth -print
9. Set the Display automatically for the current new user ?
export DISPLAY=`eval ‘who am i | cut -d"(" -f2 | cut -d")" -f1′`
Here in above command, see single quote, double quote, grave ascent is used. Observe carefully.
10. Display the processes, which are running under yourusername ?
ps .aef | grep Maheshvj
Here, Maheshvj is the username.
11. List some Hot Keys for bash shell ?
- Ctrl+l . Clears the Screen.
Ctrl+r . Does a search in previously given commands in shell.
Ctrl+u - Clears the typing before the hotkey.
Ctrl+a . Places cursor at the beginning of the command at shell.
Ctrl+e . Places cursor at the end of the command at shell.
Ctrl+d . Kills the shell.
Ctrl+z . Places the currently running process into background.
12. Display the files in the directory by file size ?
ls .ltr | sort .nr .k 5
13. How to save man pages to a file ?
man | col .b > Example : man top | col .b > top_help.txt
14. How to know the date & time for . when script is executed ?
Add the following script line in shell script.
eval echo "Script is executed at `date`" >> timeinfo.inf
Here, .timeinfo.inf. contains date & time details ie., when script is executed and history related to execution.
15. How do you find out drive statistics ?
iostat -E
16. Display disk usage in Kilobytes ?
du -k
17. Display top ten largest files/directories ?
- du -sk * | sort -nr | head
18. How much space is used for users in kilobytes ?
quot -af
19. How to create null file ?
cat /dev/null > filename1
20. Access common commands quicker ?
ps -ef | grep -i $@
21. Display the page size of memory ?
pagesize -a
22. Display Ethernet Address arp table ?
arp -a
23. Display the no.of active established connections to localhost ?
netstat -a | grep EST
24. Display the state of interfaces used for TCP/IP traffice ?
netstat -i
25. Display the parent/child tree of a process ?
ptree Example: ptree 1267
26. Show the working directory of a process ?
pwdx Example: pwdx 1267
27. Display the processes current open files ?
pfiles Example: pfiles 1267
28. Display the inter-process communication facility status ?
ipcs
29. Display the top most process utilizing most CPU ?
top .b 1
30. Alternative for top command ?
prstat -a
want to create a shell script which will check whether any integration services is down or not.
If it is down than i should get alert mails for the same.
#!/usr/bin/ksh
pmcmd pingservice -service Integration_Service_Name -domain Domain_Name -timeout 5 > status
if [ `grep -c "Integration Service is alive." status` -eq 1 ]
then
echo "Failure" | mailx -s "Integration Service is not running" xyz@...com
fi
No comments:
Post a Comment