Photo by Sai Kiran Anagani on Unsplash
Linux Commands Cheat-sheet
All the basic linux commands under 5 minutes !!
These are all the basic linux terminal commands which are required in day to day life. To use these commands, one should open the terminal in linux OS by searching it in menu (GUI) and run these commands as required.
Basic Linux Commands:
- To know the present working directory of the user.
$ pwd
- Lists all files and directories in the present working directory.
-R : to lists files in sub-directories as well.
-a : to lists hidden files as well.$ ls $ ls -R $ ls -a
- To change to a particular directory.
use ".." after cd to go to one directory up (back)$ cd DIRECTORY_NAME $ cd ..
- To create a new file.
to displays the file content
to joins two files (file1, file2) and stores the output in a new file (file3)$ cat > FILE_NAME /*or*/ touch FILE_NAME $ cat FILE_NAME $ cat FILE1 FILE2 > FILE3
- Moves the files to the new location.
this same command renames the file to a new filename also.$ mv FILE_NAME "new file path" $ mv FILE_NAME NEW_FILE_NAME
- Creates a new directory in the present working directory or a at the specified path.
this same command renames the file to a new filename also.$ mkdir DIRECTOY_NAME
- Deletes an empty directory.
8.Deletes a file$ rmdir DIRECTORY_NAME
-r : removes a directory which is not empty$ rm FILE_NAME $ rm -r DIRECTORY_NAME
- Command used to install and update packages (with install and update options respectively)
$ apt-get "[install]" "[update]" PACKAGE_NAME
- Gives manual or information about a command
$ man COMMAND
File administration commands
To perform these administration command, you need to have superuser permissions or you must be a sudoer else use
sudo
command before every command.
- To display file type and access permission in list form
- la is used to display hidden files also$ ls -l $ ls -la
For changing the ownership of a file/directory.
$ chown USER_NAME FILE_NAME
To change file and directory permissions.
+rwx filename to add permissions.
-rwx filename to remove permissions.
Note: These r w x are used separately also for allowing only respective permissions.
$ chmod +rwx FILE_NAME/DIRECTORY_NAME
- To change the group for a file or directory
$ chgrp FILE_NAME or DIRECTORY_NAME
User administration commands
To perform these administration command, you need to have superuser permissions or you must be a sudoer else use
sudo
command before every command.
- To create a new user
$ sudo adduser USER_NAME
- To change the password of a user
$ sudo passwd -l USER_NAME
- To remove a newly created user
$ sudo userdel -r USER_NAME
- To add a user to a group
$ sudo usermod -a -G GROUP_NAME USER_NAME
- To remove a user from a group
$ sudo deluser USER_NAME GROUP_NAME
- Shows information of all the users logged in
$ finger
Networking commands
- To ping and Analyzing network and host connections
$ ping URL or IP_ADDRESS
- login into a remote Linux machine using SSH
$ ssh USER_NAME@IP_ADDRESS
- Login into a FTP server
$ ftp IP_ADDRESS
- To upload files from local computer to remote computer
$ put FILE_NAME
- To download files from remote computer to local computer
$ get FILE_NAME
- to exit remote connection.
$ quit OR exit