Recent Changes - Search:

Softwares

.

LinuxCommands


Finding out which man page has the information am looking for

   #apropos        fonts

Basic Commands

   #init 0         Shutdown the system
   #init 6         reboot the system

   #hwclock --set --date="9/22/96 16:45:05"       changing the system date and time.

   #hostname -i      Display the systems IP address

   #hostname          reports the hostname of the machine

   #cat document /dev/lp0     the content of document is printed
   #ls -a   list hidden files

   #ls- ld  /varlist the dir /var with it's attributes
   #who >> A the output of the who command is appended to file A

   #less /var/log/messages 
   #tail -f /var/log/messages  -output appended data as the file grows

   #cp -rf [sourcedirectory]  [destinationdir]
   #rm -rf directoryname    deletes the directory recursiveky and interactively

   #cd .. goes back to the immediate parent directory
   #cd ~takes you back to your home directory

   #cd ~[useranme] this can take your to the home dir of the user

   #mv [oldfilelname] [newfilename]
   #df -hs    to vew the disk usage  in megabytes

   #df /dev/hda1
   #env shows the current sets of environment variable

   # apropos xine     xine                 (1)  - a free video player

   # which unzip        show full path name of command /usr/bin/unzip

nice and renice commands

nice - run a command at non-default priority

   #nice command     run a low priority command
   #renice 
   #renice -n 19 12345     # 12345 represents the PID of your process

This command will set the nice value of the process with the process ID of process_id to 19:

   #renice 19 -p process_id

19 is the level you should use for a long running process.

ps command

Generate a full listing of all processes currently running on your machine:

   #ps -ef
   #ps -ef | more
   #ps -ef | grep username
   #ps -ef | grep username | more

Examining process

   #ps -efl
   #ps -efl |more
   #ps -efl |grep username
   #ps -efl |grep username|more

Displays information about memory, cpu and disk

   # vmstat 2 5 (where 2 is delay and 5 is count)

Displays statistics about cpu utilization

   # mpstat 1 4

Displays statistics about the disk system

   # iostat -dk 1 4

-d - Gives the device utilization report. -k - Display statistics in kilobytes per second.

Displays overall system performance.

    [root@ibm html]# sar

GPG encrypt a file

   #gpg -c file      encrypt file
   #gpg file.gpg     decrypt file

Using find command Commands

   #find / -name *.pl  -print  finds the file with .pl from the filesystem root
   #locate  /root
   #slocate httpd.conf    the /var/lib/slocate/slocate.db should be updated for this to work.

   #uname -r gives out the current kernel version
   #lsmod list currently loaded modules
   #modeprobe ide-scsi will load the module for SCSI emulation
   #lspci list the currently detected pci cards
   #dd if=/dev/cdrom of=/root/cdrom.dd    will copy the content to a file.

Burning Cd using cdrecord command

   #cdrecord -scanbus    shows the emulated cd writer
   #cdrecord -v speed=8 dev=0,0,0 /root/cdrom.dd   duplicates the file

   #gzip < /dev/cdrom > cdrom.iso.gz         save copy of data cdrom
   #mkisofs -r dir | gzip > cdrom.iso.gz     create cdrom image from contents of dir
   #mount -o loop cdrom.iso /mnt/dir    mount the cdrom image at /mnt/dir (read only)


  1. gzip -dc cdrom.iso.gz | cdrecord -v dev=/dev/cdrom - burn cdrom image

(use dev=ATAPI -scanbus to confirm dev)

   #cdparanoia -B      rip audio tracks from CD to wav files in current dir
   #cdrecord -v dev=/dev/cdrom -audio *.wav  make audio CD from all wavs in current dir 
   (see also cdrdao)

Creating iso files

   #mkisofs -J -R /document.iso  /document    this makes the iso image

of the directory document to document.iso, we can use the cdrecord command to burn it.

How to create directory with parenting

   #mkdir -p /1/2/3/4/

To create aliase for a commnad

   #alias mkdir=mk   -to set alias for mkdir command

Piping Commands in Linux

   # cat /etc/passwd |sort |less

Here the sort command sorts the passwd file automatically.

   #gunzip   <  /usr/share/man/man1/grep.1.gz |nroff -c -man |less  

   grep.1.gz is redirected to the gunzip command to be unzipped 

Sequential Commands

   #date; troff -me document |lpr; date

   troff - the troff processor of the groff text formatting system.

Grep Commands

Grep - Global Regular Expression Parser

   #grep ftp /etc/services
   #grep ^ftp /etc/services -{to get the strings begining with ftp}
   #grep effect$ /etc/services - {to get the strings ending with effect}
   #grep -v ^# /etc/services { dispaly excluding the lines starting with # }

   #grep -i {case insensitive}
   #grep -i Ftp /etc/services
   #grep -l "192.168" *  { only displays the file that contains the character }
   #grep -l 192\.168 *
   #grep -l '192.168' *

Using the Cut

   #cut -d : -f 7 /etc/passwd | head -2 
   #cut -d : -f 7 /etc/passwd | uniq 

   #cut -d : -f 7 /etc/passwd |sort| uniq 
   #cut -d : -f 7 /etc/passwd  

The commands will allow to print out the seventh field in the passwd file.

Using the Sed Command

Sed - Sed is a Stream Editor

   #sed -i s/nologin/login/g /etc/passwd 

This command replaces the word nologin in the file /etc/passwd globally with login.

   #sed -ibackup s/nolgin/login/g /etc/passwd

This command takes the backup copy of the file /etc/passwd before editing.

Using the tmpwatch Command

               tmpwatch  -uav  1  /tmp
               tmpwatch  -  removes  files which havenāt been accessed for a period of time.

Tmpwatch recursively removes files which havenāt been accessed for a given number of hours. Normally, itās used to clean up directories which are used for temporary holding space such as /tmp.

              -v, --verbose
              -u, --atime
              Make  the  decision  about  deleting  a file based on the fileās
              atime (access time). This is the default.
              -a, --all
              Remove all file types, not just regular files and directories.

Setting the system clock

To set the system clock under Linux, use the date command. As an example, to set the current time and date to July 31, 11:16pm, type ``date 07312316'' (note that the time is given in 24 hour notation).

netstat

         netstat -a
         Active Internet connections (servers and established)

         netstat -an   [-n flag to turn off DNS lookups]

Netstat can help diagnose NIC problems. Use the -i flag

         netstat -i

Run any command in the background

   command&  (example  - knotes&)

Run any command in the background (the symbol "&" means "run the preceding command in the background").

Compress a file with bzip2/tar

         bzip2 -z -9 filename

Decompressing the file is simple using the command bunzip2 -d <filename>. For example:

         bunzip2 -d toobig.bz2

       -d --decompress
              Force  decompression.   bzip2,  bunzip2 and bzcat are really the
              same program, and the decision about what  actions  to  take  is
              done  on  the  basis of which name is used.  This flag overrides
              that mechanism, and forces bzip2 to decompress.

       -z --compress
              The complement to -d:  forces  compression,  regardless  of  the
              invocation name.

Using ipcalc command

   [root@ibm ~]#  ipcalc -m 192.168.0.11
   NETMASK=255.255.255.0
   [root@ibm ~]#  ipcalc -b 192.168.0.11/24
   BROADCAST=192.168.0.255
   [root@ibm ~]#  ipcalc -n 192.168.0.11/24
   NETWORK=192.168.0.0
   [root@ibm ~]#  ipcalc -n 192.168.0.11/24


Edit - History - Print - Recent Changes - Search
Page last modified on April 24, 2009, at 02:31 PM