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:
$ command options arguments
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).
pwd command prints the current working directory of the shell.
- clear command clears the screen and the prompt jumpt to the top.
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:
12345drwxr-xr-x 2 saga saga 4096 Feb 20 21:27 dbdrwxr-xr-x 303 saga saga 12288 Feb 20 23:03 node_modules-rw-r--r-- 1 saga saga 454 Feb 21 09:12 package.json-rw-r--r-- 1 saga saga 93883 Feb 21 09:12 package-lock.jsondrwxr-xr-x 4 saga saga 4096 Feb 21 09:12 src
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:
1$ ln TARGET LINK_NAME