Basic unix commands for day to day use

April 13th, 2009 by Giridhar | Posted under Linux.

man cmd #display how to for a commandlinux-penguin

grep pattern  filename #searches a text file for a pattern
grep onwer *jil #search all jil files for owner

ps -auxwww | grep j2se #display if process is running

echo $SHELL #dispplay your current shell

whoami; groups | awk ‘{print $1}’; umask #display who you are
ps -auxwww | /usr/xpg4/bin/grep -e pss1 | grep j2se #display if processes are running for pss1 & j2se

chown owner /apps/wls/filename #change the owner for a file
chgrp groupname /apps/wls/filename #change group for file
chmod 755 /apps/wls/filename #change permissions for file
421
rwx
(be very cautious when doing a recursive change)

chown -R owner /apps/wls/dirname #change the owner for a dir and files in the dir
chgrp -R groupname /apps/wls/dirname #change group for a dir and files in the dir
chmod -R 755 /apps/wls/dirname #change permissions for a dir and files in the dir

newgrp <groupname> #switch to a new group

umask 022 #set the file mode creation mask
777-022=755         (files normally created with mode 777 become mode 755;
666-022=644          files created with mode 666 become mode 644)

cd /apps/wls/applications #change directory
cd ../ #back one level to /apps/wls/
pwd #current working directory

cp -p filename filename.YYYYMMDD #backup file with currect datestamp
cp ~homedir/tmp/filename filename #copy file to current directory specifying filename
cp ~homedir/tmp/*.csh . #copy all files ending in “.csh” to current directory
cp ~homedir/tmp/filename . #copy dir & all subdir & files to current directory

ls -al /apps/wls/applications/*.ear #display all ear files long list
ls -alg /apps/wls/applications/*.ear #display all ear files long list plus group
ls -ltr /apps/wls/applications/* #list by timestamp
ls -ld /apps/wls/applications #list directory owner permission
ls -ldg /apps/wls/applications #list directory owner and group
cat filename #display contents of a file no pause
cat filename |more #display contents of a file with a pause
cat file1 file2 >file3 #concatenates file1 and file2 results = file3

more filename #display contents of a file one screen at the time

tail filename #display the last few lines of a file
tail -500 filename #display the last 500 lines of a file
tail -f  log #display a log file in interactive mode CRTL-C to end

mdir direname #create a directory
mdir -p dirname/a/b/c #create all non-existing parent directories first
ex: cd /apps/wls
mkdir -p abc/data/log/stage   (this will create all dir in one pass)

/usr/bin/rm filename* #delete all reiterations of a file
/usr/bin/rm -r dirname #remove dir and it’s contents recursive

tar tvf  filename.tar #display contents of tar file
tar xvf  filename.tar ./filename.ear #extract only the specified file
tar xvfp filename.tar                                         #extract files with original modes and ACL’s
tar cvf  filename.tar ~homedir/* #create a tar file of a dir or files

jil < job.jil #add,update,and delete AutoSys jobs
autorep -J jobname -q #display autosys job details
autorep -J jobname -d #display autosys job status

find . -name “core” -type f -exec ls -al {} \; #find file named “core” from current path
find . -name “*.m” -type f -exec ls -al {} \; #find any file with named ext “*.m” from current path
find . -name “stage” -type d -exec ls -ld {} \; #find dir named “stage” from current path

find . -type d -exec ls -ld {} \; #find all dir’s from current path
find . -type f -exec ls -al {} \; #find all files from current path

dos2unix -ascii original newfile #convert windows style characters create new file
dos2unix -ascii original original #convert windows style characters same file

df -kl #display free space for local file systems
df -k #display free space for all file systems
df -k . #display free space for current working directory

ipcs -a #display info about active semaphores

ipcs -a |grep -i tsq # display semaphores for tsq

ipcrm (options -m shmid, -q msqid, -s semid, -M shmkey, -Q msgkey, -S semkey) #remove a semaphore

nslookup hostname #display IP addr for a host
ifconfig -a | grep ipaddr #display ipaddr is configured in host

view filename #view contents of a file in vi mode cannot change it

You can download a good formatted version here

Need more  tips ?


Is this article useful ?, please comment (why should I comment ?)

Tags: , , , , , ,

Comments

6 Responses to “Basic unix commands for day to day use”
  1. Wow!

    This is a great list. I’m going to safe it on my BlackBerry as this will come in very handy!

    Did you compile this list yourself?

  2. Rangaswamy says:

    Hello,

    This is looks like packet not book. Very much useful.

  3. Rangaswamy says:

    This is looks like packet note book. Very much useful.

  4. Kumar G says:

    Information is very useful. thanks for sharing the info. as handy.

Have any comments?