Skip to end of metadata
Go to start of metadata

Analyze Disk Drives

Command Description
df summarize free space on disk drive
du show disk space used by files or directories

Analyze CPU Utilization

Command Description
top or topas provides a rolling display of top cpu using processes

Navigate the File System

Command Description
cd d Change to directory d
ls
list the contents of the current directory
ls -la
list all contents of the directory in long format
ls -latr
list all contents of the directory in long format with the latest modified files last (handy to show the latest modified files at the bottom of the list where the prompt awaits your next command).
pwd See what directory you are currently in; this writes the absolute pathname of the current working directory to the standard output

Search the File System

Example of searching for a file in the current directory and any subdirectories witha wildcard in the file name:

find . -name "*ConfigService.properties" -print

See also: http://www.athabascau.ca/html/depts/compserv/webunit/HOWTO/find.htm#EX01

Read and Edit Files

Command Description
vi filename open a text file for reading or editing in the VI Editor
cat filename print the contents of a text file to the standard output
touch filename change a file's access and modification timestamps or create a new empty file if the file does not already exist

Modify File Permissions

Command Description
chmod 755 filename Give everyone read and execute permissions to a file
chmod 777 filename Give everyone full permissions to a file

Environment control

Command Description
mkdir d Create new directory d
rmdir d Remove directory d
mv f1 [f2...] d Move file f to directory d
mv d1 d2 Rename directory d1 as d2
mv f1 f2
Rename file f1 as f2
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 [name1 name2...] remove environment variable

Output, communication, and help

Command Description
lpr -P printer f Output file f to line printer
script [f] Save terminal session to f
exit Stop saving terminal session
mail username Send mail to user
biff [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
Ctrl/z * Suspend current process
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
ps -ef | grep username List all running processes for a given user
ps -ef | grep <application name or part of app name> List all running processes for a given application
kill -9 n Remove process n
kill -3 n
Remove process n and collect the thread dumps (this can be useful to analyze the thread dumps on a hung process, for example)
stop %n Suspend background job n
command& Run command in background
bg [%n] Resume background job n
fg [%n] Resume foreground job n
exit Exit from shell


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;

Did you know?

Did you know that you can pull up a help page or manual page with information about any command directly from the Unix or Linux command line shell. Simply type:

man command

For example, to learn about the ls command and all the various parameters you can use with it, type:

man ls

To exit the manual type :q (colon and Q)

Labels:
unix unix Delete
linux linux Delete
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.