10 most used Linux commands

If you are using Linux or a newbie that these commands will help you a lot when working on Linux terminal.

1. To get a full path for the current directory

$ pwd

2. To move around

$ cd                         # go $HOME
$ cd /path/to/another/fodler # move to another directory
$ cd ..                      # move one back toward root
$ cd -                       # cd into the previous directory

3. To list the files and sub-directories in the directory

$ ls                         # list all 
$ ls -la                     # list all,including dot files and dirs
$ ls -l                      # long form
$ ls -hl                     # long form, human readable

4. To create/remove a new folder

$ mkdir name_folder           # creat a new folder
$ mkdir -p name_folder        # make nested folder
$ rm -f name_folder           # remove a folder

5. To print the contents of files

$ cat file_name               # print file with no line numbers
$ cat -n file_name            # print file with line numbers 
$ cat file.txt | wc -l        # count the number of lines in a file

6. Copy a file/directory to another place

$ cp file_name to_new_place   # copy a file to a new place
$ cp -r dir1 to_new_place     # copy a directory to a new place

7. Copy a file / directory from a remote server to local

$ scp -rf username@ipaddress:file_name/directory to_local_place      # copy a file/directory from remote server to local

$ scp -rf file_name/directory username@ipaddress  # copy a file/directory from local to remote server

8. To add or remove permissions from files or directories

$ chmod 000 file_name        # revoke all permissions
$ chmod 777 file_name        # grant all permissions (rwxrwxrwx)
$ chmod 755 file_name        # reserve write access for the user
$ chmod +x file_name         # make an executed file

Please read more here

9. To change the owner of a file

$ sudo chown someuser:somegroup your_file

10. To access to a remote computer

$ ssh username@ipaddress -p port_number  # default port number is 22

Thank you for reading!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s