Linux: Compressing-Decompressing, ps, kill, and su commands


Linux: Compressing-Decompressing-gzip and gunzip

  • To compress and decompress several utilities are available in Linux. Most software for Linux systems uses the GNU gzip and gunzip utilities
  • To compress the files gzip utility and to decompress compressed files gunzip utility is used
  • To compress a file, enter the command gzip and the filename. This replaces the file with a compressed version of it, with the extension .gz. In the following example the file suvarni is compressed and the new compressed file is suvarni.gz
  • Example: gzip suvarni

  • To decompress a compressed file, you can use either gzip with the -d option or the command gunzip. These commands decompress a compressed file with the .gz extension and replace it with a decompressed version with the same root name, but without the .gz extension
  • When you use gunzip, you need not type in the .gz extension because gunzip and gzip -d assume it. In the following example suvarni.gz file is decompressed
  • Example: gunzip suvarni.gz

  • If you want to display or print the contents of a compressed file without first decompressing it. You can do this with the command zcat which generates a decompressed version of a file and sends it to the standard output. You can then redirect this output to a printer or display a utility such as more. But the original file remains in its compressed form
  • Example: zcat suvarni.gz | more

  • You can also compress an archived tar files. This results in files with the extensions .tar.gz. These compressed archived files are generally used for transmitting extremely large files across networks
  • In the following example the archived file krtihi.tar is compressed. The new file will have an extension krithi.tar.gz
  • Example: gzip krithi.tar

  • You can even compress tar file members individually using the tar z option which invokes gzip. For this the z option be used, tar invokes gzip to compress a file before placing it in an archive
  • Archives with members compressed with the z option, however, can neither be updated nor added to. All members must be compressed and all must be added at the same time

Linux : ps command

  • The ps command is used to displays a lot of information
  • In the next example the ps command lists the processes a user is running
  • In the listing the PID is the system process number, also known as the Process ID. TTY is the terminal identifier. The time is how long the process has taken so far. COMMAND is the name of the process
  • Example: ps

    PID TTY TIME COMMAND
    523 tty13 0:58 sh
    570 tty13 0:00 ps
  • Consider the option –aux with ps command. The -a option of aux tells ps to list the processes of all users on the system rather than just those of the current user, with the exception of group leaders and processes not associated with a terminal. A group leader is the first member of a group of related processes
  • The -u option of aux tells ps to provide detailed information about each process
  • The -x option of aux adds to the list processes that have no controlling terminal, such as daemons, which are programs that are launched during booting and run in the background until they are activated by a particular event or condition
  • Example: ps -aux

  • The output of the aux command can be given as input to grep command to search for a specific process. In the following example the command lists the process for the Web server
  • Example: ps -aux | grep 'httpd'

  • If you want to obtain complete information about the processes currently on the system is to use the following command
  • Example: ps -aux | less

Linux: kill command

  • If you want to stop a specific process then you can reference the system process number in a kill command
  • In the next example the process 567 is terminated
  • Example: kill 567

Linux: SU (Switch User)

  • While you are logged into a regular user account, sometimes it may be necessary for you to log into the root and become a superuser. Generally, you would have to log out of your user account first, and then log into the root
  • Instead, you can use the su command (switch user) to log in directly to the root while remaining logged into your user account
  • A CTRL-D or exit command returns you to your own login
  • When logged in as the root, you can use su to log in as any user, without providing the password

Linux: Filter commands cut, wc, spell and sort << Previous
Next>> Linux: split and Paste command


Our aim is to provide information to the knowledge seekers. 


comments powered by Disqus






Footer1