Linux Commands for Beginners (Part 1)
Welcome Linux-fanatics, In this post I will be showing you some basic Linux commands which are very important & used very frequently. This post will be very useful for those users who are new to Linux CLI & have just moved from Windows.
$ pwd shows us the present working directory ,
$ cd is used to change directory. It is used with number of options, some of important ones are mentioned below:-
- $ cd – move one directory back
- $ cd .. change from child directory to parent directory.
- $ cd — move back to previous working directory
- $ cd ~ move to home directory from anywhere
$ ls lists files/folders i.e. shows all the files & directories. It also has a number of useful options, some are listed below:-
- $ ls –l shows all files/folders with size, modified date & time along with owner & permissions of the files/folder
- $ ls –a shows all hidden files (hidden files start with “.”)
- $ ls –lH shows all files/folders in human readable format
- $ ls –lS will sort the files as per their size
- $ ls –I will show inode number
$ touch is used to create an empty file
$ rm is used to remove a file
$ cp is used to create a copy of file. Syntax for command “ cp source destination”
$ mv is used to move a file from its location. Its syntax is same as cp command. It can also be used to rename a file, just place original name in place of source & desired name in place of destination.
$ mkdir is used to create a directory
$ rmdir is use d to remove an empty directory. To delete a directory with all its content use “rm –rf directory_name” (use wisely , data removed is permanent)
$ file shows file name along with file-type
$ cat short for “concatenate” , shows content of files. It has a number for functionalities
- $ cat file1 file2 read multiple files
- $ cat >filename creates a file & wait for user to write content in file. Once done press CTRL+D to save file
- $ cat file1 > file2 redirects file1 content to file2. Multiple files can be redirected. Can also be used to clone a whole drive (cat /dev/sda1 /dev/sdb2)
$ more lets you scroll the output of a command
$ less more powerful version of more command .
$ tail displays last few lines of file. It can be used with –n option to show n last number of lines
$ head displays first few lines of a file. It also can be used with –n option.
$ history shows history of all commands executed. History command with a number n, will show last n commands in history
That’s it guys for now. Also read my Basic Bash Shell commands part 2 post with some more basic but important Linux commands.
Also, don’t forget to leave your valuable feedback/queries down below.