Must know ssh Linux commands to learn Today
LinuxUsing 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.
10. The cd command
11. The cp command
12. The find command
13. The ping command
14. The wget command
Table of contents [Show]
- 0. 1 2. To Create and View Files
- 0. 2 3. Deleting Files
- 0. 3 4. File rename and Move
- 0. 4 5. Create Directories
- 0. 5 6. Remove Directories
- 0. 6 7. Renaming Directories
- 0. 7 8. History Command
- 0. 8
- 0. 9 9. The clear command
- 0. 10 10. The cd command
- 0. 11 11. cp command
- 0. 12
- 0. 13 12. find command
- 0. 14 13. The ping command
- 0. 15 14. The wget command
- 1 In Conclusion
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.
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.
To get a detailed information of files, you can use the list command "ls -al". This information will be displayed in form of columns.
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".
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.
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
To view the combined files, simple use;
$ cat newFile
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
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
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
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
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
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.
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.