Linux Command Line Tutorial

Linux command line is an awesome tool with almost limitless functionality. This post will be a tutorial of basic command line utilities.

This is how you enter commands at a shell:

The command is followed by options (optional of course) and a list of arguments. The options can modify the behavior of a command. The arguments may be files or directories or some other data on which the command acts. Every command might not need arguments. Some commands work with or without them (e.g. ‘ls’ command).The options can be provided in two ways: full word options with — (e.g. –help), or single letter options with – (e.g. -a -b -c or multiple options, -abc).

Basic Commands:

  • pwd command prints the current working directory of the shell.
  • clear command clears the screen and the prompt jumpt to the top.
  • cd
    Change the current working directory to the directory provided as argument. If no argument is given to ‘cd’, it changes the directory to the user’s home directory. The directory path can be an absolute path or relative to current directory. The absolute path always starts with /.
  • ls lists the files and directories in the current directory. If no argument is given, the contents of current directory are shown. If a directory is given as an argument, files and directories in that directory are shown.
    ls -l displays long listing of directories:

    In this long listing, the first character is ‘d’ or ‘-‘. It distinguishes between file types. The entries with a ‘-‘ (dash) are regular files, and ones with ‘d’ are directories. The next 9 characters are permissions (‘rwxr-xr-x’ in first listing). The number following the permissions is the link count. Link count follows user and group owner. In the above example, the file owner is ‘raghu’ and group owner is ‘raghu’ as well. Next is the size of the file. And then time stamp before the name of file (or directory).
    By default, hidden files or directories are not shown, to see hidden files as well, -a option is used. Hidden files in Linux start with a period sign (.). Any file that starts with a period is hidden. So, to hide a file, you just need to rename it (and put a period before it).
  • Use mkdir command to create a directory.
  • The ln command is used in linux to create links (shortcuts). Links are a kind of shortcuts to other files. The general form of command is:

     

Leave a Reply

Your email address will not be published. Required fields are marked *