Sei sulla pagina 1di 6

101 Unix Commands

101 UNIX Commands


Document Index Ref: 101 Unix Commands

Internal Use Only

This document is confidential and for internal use only. The information contained herein is the property of IBM and may not be copied, used or disclosed on whole or in part, stored in a retrieval system or transmitted in any form or by any means (electronic, mechanical, reprographic, recording or otherwise).

Page 1 of 6

101 Unix Commands

Objective This document intends to provide the list of UNIX commands used by AIX/Solaris/Unix admins day to day operation. No Commands $ ssh username@servername command used to login to server $ cd.. takes you to previous Dir $ vi <file_name> opens file for reading/editing $ grep <pattern> file_name checks pattern/word in file name specified $ ln file1 file2 creates link of file1 to file2 $ clear clears the scree $w will display more info abt the users logged in $ rm <file_name> will delete file specified $ rm * Delete all the files in the present directory (BE CAREFUL WHILE GIVING THIS COMMAND) $ chmod 777 <file_name> changes file_name/directory permissions use R switch for recursive $ rsh -l <login_name> <server_name> No Commands $ pwd it prints present working directory $ mkdir <directory> will create directory $ cat <file_name> display contents of file $ head <file_name> shows first 10 lines of file_name No Commands $ ls -l listing the files in present directory $ mkdir -p /home/user1/d1/d2/d3 will create all the non-existing Dirs $ more <file_name> displays page by page contents of file $ touch <file_name> creates a zero/dummy file

4 7

5 8

6 9

10

11

12

13

14

$ cp <file1> <file2> Copy a file $ who Displays logged in user to the system. $ ps -ef shows process

15

$ mv <file1> <file2> Move/rename a file or folder $ file <file_name> shows what type of file it is like $ which <file_name> shows if the file_name/command exists and if exists display the path $ tail <file_name> shows last 10 lines of file use tail -f for continous update of file_name

16

17

18

19

20

21

22

23

$ find . -type f -print -exec grep -i <type_ur_text_here> {} \; this is recursive grep $ find / -name <file_name> -print

24

25

26

$ chown owner:group <file_name> changes owner & group for the file_name $ rcp file1 file2 Copying file to remoter servers (This requires preconfiguration on remote servers like .rhosts & hosts.equiv)

27

$ chgrp <groupname> <filename> use R for recursive

28

29

30

$ gunzip <file_name> unzips file name $ gzip <file_name> zips file_name

Page 2 of 6

101 Unix Commands No Commands No Commands No Commands

31

$uncompress <filename> uncompresses filename $ crontab -l Shows the cron jobs running/scheduled for the current user. -->$crontab -l > present_cronjobs -->edit/add entries to present_cronjobs -->$crontab present_cronjobs (This will submit/resubmit the jobs in file presnt_cronjobs to CRON) $ nohup <cmd_name> & nohup is very useful command. it runs the command even the telnet connection is closed/broken. & is used for running command in background. $ id shows current user's UID, username and GID and group name $ isainfo -v shows supported platforms (32-bit, 64-bit) $ rm - <-filename> for deleting special files $ rm "<file name>" delete file names with spaces in between $ du sk <dir/file name> Display the size of the files/folder $ pkginfo Gives/shows info about installed packages/software on system $ init 6 will reboot the system (other init options are 1, 2, 3, 5 and S)

32

$ compress <file_name> compresses file_name $ at $ at -l will show the at jobs scheduled at schedule a job to run later time at <time> command/script (will run the script at specified time)

33

$ bc -l bench calculator killing an unwanted process $ps ef | grep <process_name> (will show the PID of the process in the 2nd field)

40

41

42

$kill -9 <PID> $ kill -3 <PID> Used to take threaddump of java process

43

44

$ uptime will show how long the system has been up and also shows cpu load, number of users logged in etc.

45

$ last Will show the users logged in/out information last <user_name> shows particular user logins/logouts last reboot shows all the system boots $ uname -a will show system name, solaris version, platform and some more information $ env List the environmental variables set to your current session $ echo $TERM Shows terminal type like vt100, vt220 etc. ($PATH, $ORACLE_HOME etc can be used with echo) $ mount will show all mounted file systems with additional info like large filesystem support etc $ init 0 will shutdown the system tar -cvf allfile.tar /<directory_name> copies all files under directory to allfile.tar $ tar -xvf allfile.tar /home

$ hostid 47 shows unique identifier of host $ hostname will give your system name. 48

46

49

50

51

52

53

$ useradd <username> Adding a user to the system $ userdel <username> Deleting a user from the system $ df -k will show all the mounted filesystems. $ showrev p shows all patches installed on system $ alias l='ls -l' alias dir='ls -l|grep "^d"' alias p='pwd' alias c='clear' Short cuts for commonly used

54

55

56

57

58 61

59 62

60 63

Page 3 of 6

101 Unix Commands No Commands No Commands commands No Commands retrieves tar files to /home directory $ tar -tvf allfile.tar reads contents of allfile.tar $ set -o vi While your shell is set to KSH use this command to display history of commands you are typing Press ESCAPE and k for showing previous commands $ mount will show the disks mounted and all partitions $ cd /usr/platform/sun4u/sbin/prtdiag -v shows additional configuration of memory, cpu speed etc.. $ mpstat shows multi cpu statistics like load on each cpu. $ prstat shows process related statistics (present from solaris 2.7 and above) $ psrinfo gives processor/s information (online/offline) $ strings <file_name> shows printable strings in any type of file (binary, object, text etc) $ uadmin 2 0 stops system immediately within 5 seconds(BE CAREFUL-- has to be to root) $ dos2unix <filename> Convert dos formatted file to unix format

64

67

$ /usr/sbin/ifconfig -a Will show the ip-address of the system. lo0 : loopback interface hme0 : hundred MBPS n/w interface qfe0 : quad ehternet interface $ ifconfig unplumb hme0 will disable ehternet interface hme0 $ top shows all process and memory, cpu etc utilisation

65

$ ping <hostname> will ping and test connectivity between your system and the hostname you give in the ping. you can also give ping <ipaddress>

66

68

$ ifconfig plumb hme0 will enable hme0 $ prtconf shows h/w, cpu, memory conf

69

70

71

72

73

76

79

$ sysdef shows system h/w, memory, and other internal configurable/tunable paramters $ iostat disk utilisation, cpu, io wait etc (iostat -xcM gives extented statistics of disk activity, cpu etc) $ netstat shows network statistics $ truss -p <PID> shows system calls and signals (useful when debugging process) $ format will show all the disks configuration and partitions $ halt halts processor and reboots machine (BECAREFUL -has to be root) $ mkfile 60m <swap file name> creates a filename of size 60mb which can be used for adding to swap space

74

$ sar A system archive report, gives total system report for cpu, memory, disk, etcc $ vmstat memory and virtual memory utilization $ lsof -p <pid> List the opened files for the process $ stty erase ^H sets backspace for deleting typed character $ prtvtoc shows disk partition/geometry info $ adb debugging tool (for reading/debugging corefiles) $ swap -a <swap file name> attaches the 60mb file to swap space (Very useful when swap space is running out)

75

77

78

80

81

82

83

84

85

86

87

88

89

90

$ swap -l lists the swap contents 93

91

92

Page 4 of 6

101 Unix Commands No Commands $ sleep 5 waits for 5 seconds (useful in shell scripts) No Commands $ cat <file_name> |awk '{print $1}' Prints the first field of the filed ($1, $2... can be used to display more fields) $ ksh x <file name.sh> Will compile the shell file line by line No Commands :1,$s/<old>/<new>/g use the above for global replacement of text in ascii files using vi editor
PS1=[$ (hostname)]'$ORACLE_SID@$PWD >' Add this entry on .profile , you can view the hostname , $VARIABLE,current directort path

94

95

96

97

:1,$s/^M//g remove Ctrl M character in text files using vi editor

98

99

100

$ipcs mb Will provide the shared memory information

10 1

$ mailx -s"<Subject Name>" user1@cognizant.com.com < file.txt Will send this file.txt to a mail $ uuencode $file $file| mail -s "<Subject Name>" user1@domian.com Will send the files as an attachment.

Important Directories to Remember / Root Directiry of unix system /usr/bin This directory cotains all user level unix commands /usr/sbin This directory Contains administrative related commands /usr/lib /etc This directory contains libraries This directory contains system configuration files

/var/adm This directory contains system/application logs. /etc/rc.d This directory Contains all startup scripts.There will be more of this kind rc2.d, rc3.d, rc0.d, rc5.d, rc6.d each directory has scripts which will run in its own run level. /opt In general, this directory used to install the 3rd party optional packages. /proc This contains the snapshot of the system process and memory status. Important files to remember /etc/passwd it will show all the logins, home directories of the users. /etc/shadow shows password encryption info and other user related info (only root has access to this file) /etc/system This file has all n/w, h/w, memory etc tunable parameters/values /etc/inittab This file defines the default run level of the system. /etc/hosts This file contains the list of hosts/IP address /etc/services This file contains the port/service Name /etc/nsswitch.conf This file is used to configure which services are to be used to determine information such as hostnames, password files, and group /etc/ntpd.conf This file is used to configure Network Time Deamon /etc/inetd.conf This file tells which ports to listen to and what server to start for each port /etc/syslog.conf This file have the configuration log file location and rotation sequence /etc/sudoers contains the list of user names with the command allowed to execute by the user with additional privileges /etc/fstab This file contains the list of file system and it mount points /etc/resolv.conf contains the DNS server names for the name resolution

Page 5 of 6

101 Unix Commands No Commands No Commands No Commands

Page 6 of 6

Potrebbero piacerti anche