Must know ssh Linux commands to learn Today

Linux

Using commands will make your experience with using Linux interesting.

Commands is equivalent to "programs" because when you run a command, a program code assigned for the command is executed.

Knowing basic SSH commands is very important for managing Linux server, VPS or Dedicated Server. It is the most effective way to navigate through your system and modify folders or files.

What we shall learn;

1. The "ls" Command - To list directories and files in your current directory.

2. Command to Create and View Files.

3. Deleting Files command.

4. File rename and Move

5. Create Directories

6. Remove Directories

7. Renaming Directories

8. History Command

9. The clear command

10. The cd command

11. The cp command

12. The find command

13. The ping command

14. The wget command

 

1. The "ls" Command - To list directories and files in your current directory.

This command enables you to see all the files and folders existing in your current Directory. Sometimes it is very essential to see what files and directories there is in your server.

 

 7SGXimF.png

Note that:

Files are signified by White.

Directories have a blue colour.

 

Additionally, it is also possible to get all the files contained in sub-folders or sub-directories. This is where the command "ls -R" comes to play.

 

 JhR5qGP.png

 

To get a detailed information of files, you can use the list command "ls -al". This information will be displayed in form of columns.

BeuxYY6.png

 

Finally, you can also list hidden files which will not be usually visible with the above list command unless you apply a special command "ls -a".

 

 iaww6J4.png

 

2. To Create and View Files

In order to display text files, the "cat" command is used. We can also use this command to create, copy and combine new text files. Let’s try this out.

To get started with creation of a new file, the following steps should be used;

1. cat > file1

2. Add content to this file

3. Press "ctrl + d" to return to command prompt.

 

 QbaAbjj.png

xNEQQDL.png

O9V7Erd.png

 

This is what we did;

We created a file with name "file1" and Entered the content "This is file one"

Also, we created another file "file2" with content "This is file two"

To combine the files created above, we will use;

$ cat file1 file2 > newFile

 nG6I3Ar.png

To view the combined files, simple use;

$ cat newFile

 TEQQYqb.png

It is important to note that only text files can be displayed and combined using the above command.

 

3. Deleting Files

To delete files from your current directory, the "rm" command is used. This will remove the file without confirmation to the user.

$ rm newFile

HT3Tq8H.png

 

4. File rename and Move

In order to move a file to a new location, use;

$ mv file new_file_location

Where file is the file you want to move while new_file_location is the new file location.

For example, we can move a file "file1" to a new location "/home/new/location" via the following command;

$ mv file1
$ /home/new/location

 0Y2oq1j.png

Note: Move command might need super user permission. To get through this, use sudo before applying the command.

To rename a file, simply use the following command;

$ mv file newFile

Where file is the current file name and newFile is the new file name to be changed to.

 

5. Create Directories

To create a directory, simply use the following command;

$ mkdir directoryName

 9ev8P7v.png

 

6. Remove Directories

Removing a directory will delete all files in the current Directory. In order to remove a Directory in linux, use the following command;

$ rmdir directoryName

 Jyc3sLq.png

 

7. Renaming Directories

The rename directory command is similar in nature with the move command stated earlier in this tutorial. To rename a Directory, us;

$ mv directoryName new_directory_name

8. History Command

It is vital to review all the commands you have used in the past for the current terminal session. To show all the commands, use;

$ history
 

 

 

9. The clear command

The clear command will enable your clear all fields from the window you are working on to give room for you.

To clear the current session, simply use;

$ clear

 uugCevD.png

 

 

10. The cd command

In order to move around and navigate through the different directories and paths, the cd command comes in handy.

Let’s say you are in a current Directory /home/directory

and you want to move one step back to the /home Directory , then all you have to do is to use the following command;

$ cd /home

You can also implement this by using shortcuts commands like this;

  • cd .. This will help to move one directory up
  • cd    This will take you to the home folder directly
  • cd-    This will move to the previous directory.

 

11. cp command

The cp command will copy a file to an assigned directory. Let’s say, you have an image file "image.png" and you want to copy it into the directory "/home/directory" then the command to make this work would be;

$ cp image.png /home/directory

 

12. find command

The find command is used to search for files and folders. Let's say you are looking for a file named "example.txt" in the /home/ directory, you need to simply do;

$ find /home/ -name example.txt

Alternatively, you can use the find command to ;

Get files in the current directory - find . -name example.txt

 

13. The ping command

The ping command is used to test the connectivity status of your web server. Let's say you are trying to test facebook.com, to test if this server is connected or not, simply do;

$ ping facebook.com

14. The wget command

The wget command will help you to download files from an internet resource. Let's say you want to download from http://ubuntu.com/ubuntu , To achieve this, simply do

$ wget ubuntu.com

 

In Conclusion

These are some of the useful commands used for Linux operations.

If you are having any issue with using commands in Linux or you want us to do a software installation on Linux, contact us Here.

 


Conclusion

Best commands used for Linux operations to administer Linux Servers via SSH. To use Linux , commands are very essential in order to execute actions and programs to do a particular task in a server.

Your Cart