November 18, 2015

Filled Under: , , , , ,

Basic SHELL Commands

linux linux commands shell shell commands unix unix commands

What is SHELL ??

The SHELL used to be the only user interface available on a UNIX computer.
It is a UNIX term used to describe the user interface with an operationg system.
We can also call the SHELL a command interpreter because bassicaly it can understand and execute the commands that the user enters.

Basic Commands

  1. cat -   Show a file.

    cat file1                       : list file1 to screen
    cat file1 file2 > files         : add all files together into files
    cat *.txt > files               : add all .txt files together
    cat file1 file2 | grep fred     : pipe files
    
    
    
    
  2. cd -    Change current directory
    cd : go to home directory
    cd ~/documents : go to /home/user/documents
    cd ~firstname : go to /home/firstname
    cd dir : go to directory (relative)
    cd /dir1/dir2... : go to directory (absolute)
    cd - : go to the last directory
             
  3. cp -  Copy file(s)
    cp file1 file2                      : copy file1 to file2
    cp file1 directory                  : copy file1 into directory
    cp file1 file2 ... directory        : copy files into directory
    cp -R dir1 dir2/  : copy dir1 into dir2 including subdirectries
    cp -pR dir1 dir2/ : copy directory, preserving permissions
    
    
  4. date -  Shows current date

    
    
  5. dvips - :  Convert a dvi file to PostScript
    dvips document.dvi        : convert document.dvi to document.ps
    dvips -Ppdf document.dvi  : convert to ps, for conversion to pdf
    
    
  6. file -  Gives you the type of the file and some other details
         
  7. grep  -  Look for text in files.

    grep "hello world" file1 file2 ... : look for 'hello world' in files
    grep -i "hello world" filename     : ignore capitals in search
    cat filename | grep "hello world"  : use pipe
    grep -v "hello" filename           : list lines that do not include hello
    
    
  8. gtar - GNU version of the tar utility. It allows to put files together in one archive file.

    gtar cf desq.tar dir1       : put contents of directory into desq.tar
    gtar czf out.tar.gz dir1    : write compressed tar, out.tar.gz
    gtar xf by.tar              : extract contents of by.tar here
    gtar xzf by.tar.gz          : extract compressed by.tar.gz
    gtar xf by.tar file.txt     : extract file.txt from by.tar
    
    
  9. gzip / gunzip - GNU Compress files into a smaller space, or decompress .Z or .gz files.

    gzip file.fits          : compresses file.fits into file.fits.gz
    gunzip file.fits.gz     : recovers original file.fits
    gzip *.dat              : compresses all .dat files into .dat.gz
    gunzip *.dat.gz         : decompresses all .dat.gz files into .dat
    program | gzip > out.gz : compresses program output into out.gz
    program | gunzip > out  : decompresses compressed program output
    
    
  10. info gtar - documentation for gtar
    
    
  11. latex - Convert a text file to dvi
           
  12. logout/exit : Closes the current shell.
                 
  13. ls - Show lists of files or information on the files

    ls file     : shows if the file exists
    ls -l file  : information about the file
    ls *.txt    : show files .txt
    ls -lt      : show information about files in date order
    ls -lrt     : above reversed in order
    ls -a       : show all files and all the hidden files
    ls dir      : show contents of directory
    ls -d dir   : shows if the directory exists
    ls -p       : adds meaning characters to ends of filenames
    ls -R       : show files also in subdirectories of directory
    ls -1       : show one file per line
    
    
  14. man - Get instructions for a particular Unix command .

    man man      : get help on man
    man grep     : get help on grep
    man -s1 sort : show documentation on sort in section 1
    
    
  15. more - Show a file one screen at a time

    more file                : show file one screen at a time
    grep 'frog' file | more  : Do it to output of other command
    
    
  16. mv - Move file(s) or rename a file

    mv file1 file2                     : rename file1 to file2
    mv dir1 dir2                       : rename directory dir1 to dir2
    mv file1 file2 ... directory       : move files into directory
    
    
  17. openoffice.org - a free office.

    
    
  18. passwd - change password
     
  19. pwd - Show current directory
     
  20. quota - Shows you how much disk space you have left
     
  21. rm - Delete files

    rm file1     : delete a file 
    rm -r dir1   : delete a directory and everything in it   
    
    
  22. rmdir - Delete a directory

    rmdir dirname (id it's empty)
    rm -r dirname (if it's not empty)
     
  23. thunderbird - Start mozilla thunderbird.

I hope this article was helpful and for any suggestions leave a comment bellow

0 commentaires:

Post a Comment

 

Click if you're interested

Copyright © Everything you need to know ™ is a registered trademark.