Basic Unix Commands


  • ls --- lists files
    ls -l --- lists files in 'long format', I.E. size of the file,  owner of the file, who has the right to look at it or the privileges and last modification information.
    ls -a --- lists all files, including the ones whose filenames begin in a dot
  • more filename --- shows the first part of a file, that much is displayed on one screen. To see more spacebar is returned or can be pressed to quit. /pattern can be used to search for a pattern.
  • emacs filename --- is an editor that allows to create and edit a file.
  • mv filename1 filename2 --- moves a file i.e. gives it a different name, or moves it into a different directory
  • cp filename1 filename2 --- copies a previously existing file.
  • rm filename --- removes a file. The option rm -i, asks for confirmation before actually deleting anything.
  • diff filename1 filename2 --- compares files, and shows where they differ from each other.
  • wc filename --- wc or ‘word count’; counts the number of words  in a file.
  • chmod options filename --- it allows to change the read, write, and execute permissions on  files for users- owner,others or group. chmod o+r filename makes the file readable for everyone, and chmod o-rfilename will make it unreadable for others again.
  • File Compression commands
    • gzip filename --- compresses files. Normally text files are compressed to about half their original size. gzip usually provides the highest compression rate. Gzip produces files with the ending '.gz' appended to the original filename.
    • gunzip filename --- uncompresses files compressed by gzip.
    • gzcat filename --- helps to look at a gzipped file without actually having to gunzip it (same asgunzip -c). ng gzcat filename | lpr helps to print compressed files directly.
  • printing
    • lpr filename --- print. The -P option is used to specify the printer name in case  to use a printer other than default printer.
    • lpq --- check out the printer queue, e.g. to get the number needed for removal, or to see how many other files will be printed before yours will come out
    • lprm jobnumber --- removes something from the printer queue. Job number can be found by using lpq.
    • genscript --- converts plain text files into postscript for printing, and also provides some options for formatting
    • dviselect --- to print only selected pages.
  • mkdir dirname --- make a new directory
  • ls --- Lists the contents of a directory “ls option dirname” lists content of “dirname” directory. If “dirname” is omitted, it lists current directory. Option “–l” gives a more information showing file type, size, owner and modification date of each file.
  • man : Show any UNIX command usages “man command” shows purpose of command, its format, how to specify options and usage examples.
  • ping – Use to check network reachability to a host
  •  
  • cd dirname --- change directory. 'cd ..' will gets one level up from current position
  • pwd --- tells the current path.
  • ff --- ‘find files’ helps to find files throughout the system.
  • ff -p --- This can be useful for finding other things on the system, e.g. documentation. Here only beginning name of file is sufficient too find it i.e. full name is not required.
  • grep string filename(s) --- looks for the string in the files. grep has several varieties (grepegrep, andfgrep)
  • finger username --- gives information about the last users, e.g. when they last read their mail and whether they're logged in or not etc.
  • last -1 username --- tells when the user last logged on and off and from where.
  • elm --- allows users to send e-mail messages to people around the world.
  • rlogin hostname --- allows users to connect to a remote host
  • telnet hostname --- allows users to connect to a remote host.
  • ftp hostname --- allows users to download files from a remote host which is set up as an ftp-server.
  • lynx --- allows users to browse the web from an ordinary terminal. Here only text can be seen.
  • whoami --- returns the current username.
  • passwd --- allows the user to change their password.
  • kill PID --- kills (ends) the processes with the given ID. This works only for current user’s processes.
  • date --- shows the current date and time.
  • cal --- shows a calendar of the current month. 

Popular posts from this blog

Ubuntu Linux shortcut keys

Top 40 best Windows 7 keyboard shortcuts