Environment control
| Command | Description |
|---|---|
| cd d | Change to directory d |
| mkdir d | Create new directory d |
| rmdir d | Remove directory d |
| mv f1 [BlueGuru:f2...] d | Move file f to directory d |
| mv d1 d2 | Rename directory d1 as d2 |
| pwd | See what directory you are in |
| passwd | Change password |
| alias name1 name2 | Create command alias |
| unalias name1 | Remove command alias name1 |
| rlogin nd | Login to remote node |
| logout | End terminal session |
| setenv name v | Set env var to value v |
| unsetenv [BlueGuru:name1 name2...] | remove environment variable |
Output, communication, and help
| Command | Description |
|---|---|
| lpr -P printer f | Output file f to line printer |
| script [BlueGuru:f] | Save terminal session to f |
| exit | Stop saving terminal session |
| mail username | Send mail to user |
| biff [BlueGuru:y/n] | Instant notification of mail |
| man name | UNIX manual entry forname |
| learn | Online tutorial |
Process control
| Command | Description |
|---|---|
| Ctrl/c * | Interrupt processes |
| Ctrl/s * | Stop screen scrolling |
| Ctrl/q * | Resume screen output |
| sleep n | Sleep for n seconds |
| jobs Print | list of jobs |
| kill [BlueGuru:%n] | Kill job n |
| ps | Print process status stats |
| ps -ef |
List all running processes |
| kill -9 n | Remove process n |
| Ctrl/z * | Suspend current process |
| stop %n | Suspend background job n |
| command& | Run command in background |
| bg [BlueGuru:%n] | Resume background job n |
| fg [BlueGuru:%n] | Resume foreground job n |
| exit | Exit from shell |
Give everyone read and execute permissions to a file
chmod 755 filename
Give everyone full permissions to a file
chmod 777 filename
Displays information about total space and available space on a file system
df
Flags
- -g Displays statistics in units of GB blocks. The output values for the file
system statistics would be in floating point numbers as value of each unit in
bytes is significantly high.
- -i Displays the number of free and used i-nodes for the file system; this output
is the default when the specified file system is mounted. - -I Displays information on the total number of blocks, the used space, the free
space, the percentage of used space, and the mount point for the file system. - -k Displays statistics in units of 1024-byte blocks.
- -m Displays statistics in units of MB blocks. The output values for the file
system statistics would be in floating point numbers as value of each unit in
bytes is significantly high. - -M Displays the mount point information for the file system in the second
column. - -P Displays information on the file system in POSIX portable format.
- -s Gets file system statistics from the VFS specific file system helper instead
of the statfs system call. Any arguments given when using the -s flag must be a
JFS or Enhanced JFS filesystem mount point or device. The filesystem must also
be listed in /etc/filesystems. - -t Includes figures for total allocated space in the output.
- -v Displays all information for the specified file system.
Display the number of files in a directory
ls -lt | wc -l
Display running processes...
for a user
ps -ef | grep username
for an application
ps -ef | grep <application name or part of app name>
Kill a running process
kill <process-id>
to collect the thread dumps use kill -3 <process-id>
to kill the process use kill -9 <process-id>
Get the active connection in web server user
netstat -a|grep -i est*
to get the count of the active connection use
netstat -a|grep -i est*|wc -l
Delete File that have been created before the past 5 Days
During a Support Project you may need to Delete the Logs that have been older than 60 Days
the command for that look like
find /<replace my_Directory> -mtime +5 -print | xargs rm
where mtime is the File last modification time
Determine the last Day of Month
I found this in net.This script is useful in finding the last day of the month.
Sometime it is necessary to run a command or script on the last day of a month.
month=`date +%m`
today=`date +%e`
year=`date +%Y
lastday=`cal $month $year | grep -v "^$" | tail -1 | awk '{print $NF}'`
if [BlueGuru: $today == $lastday ]; then
echo your code runs here
fi
The grep -v command removes the last line of output if it happens to be blank and the awk command prints the last chunk of data on the line.
FTP script tips
The FTP command only give the read write permission to the owner of the file , sometimes it is necessary for the member of the group or the world to read the file or write the file , in this case you will get the File Permission denied error to over come this in your FTP script add this unmask like
This will create the file with rw-rw-rw- permission.
site umask 000
so your FTP scripts will look something like
ftp $1 << FTP_CMD
cd <your destination Folder>
site umask 000
put $fileName1
quit
FTP_CMD;