SSH is a secure shell program that allows you to connect to and run commands on remote computers. It is primarily used for logging into remote computers, executing commands on them, transferring files, and more. . SSH is a secure shell program that allows you to connect to and run commands on remote computers. It is primarily used for logging into remote computers, executing commands on them, transferring files, and more. SSH-agent: A tool used by many tools installed in an operating system to store the private keys needed for authentication. A tool used by many tools installed in an operating system to store the private keys needed for authentication. sshd: An equivalent service running on the target host.
Some Basic SSH Commands are:
1. “ls” Command #
You can enter ls at the command line to get a list of all files and directories on your system This will be preceded by a message saying type ‘ls -lh’ for long format
Also a few useful options, they are:
- -l — displays the files’ details, including the date and permissions
- -a — will displays hidden files and directories
2. “cd” Command #
Cd is like a directory, the command that allows you to switch between directories. It’s a simple command, all you have to type is cd followed by whatever directory you want to jump right into.
- cd [directory] – jump in to the directory
- cd home – if you want to go home directory
- cd home/directory1/directory2 – if you want go particular directory where in the system
- cd .. – If you want to go back simply use this command
- cd / – If you want go root directory simply type this command.
3. “mkdir” Command #
You can use mkdir command to create a directory. It has very easy syntax, mkdir (Make Directory), then the directory name to be created.
mkdir [folder name]
You can see new test directory is created on above.
4. “rm” Command #
rm (remove), this command is used to delete a file in the system
- rm [filename] – command to delete a file
- rmdir [directory] – command to delete a directory if its empty
- rm -r folderName – Also this command used to delete directory if directory not empty
Here you can see the test directory is deleted from your system.
5. “touch” Command #
With this SSH command you can create a new file, here is the syntax:
touch [file name]
There are a few steps to consider when putting together a new text file. First, you need to name your file. You can choose from any available name or make one up with no limitations. Next, you will want to write in the file using your keyboard and the default interface will show up
6. “cat” Command #
We need to use the cat command in order to display the content of a file. The syntax is below:
cat [file name]
When you’re merging multiple files, like one file with a different format or style, it will apply the changes automatically. This allows you to easily switch between your usual file and the new one.
cat info.txt info2.txt > mergedinfo.text
By merging the two info files, the content is saved in a single file.
7. “cp” Command #
This is a copy command that can be used in SSH. Here’s the syntax:
cp [options] [source] [destination]
[source] is the file or folder you want to copy
[destination] is the duplicate file or folder
When yourfile.txt is you current file, If you want to make a copy of an existing file, it’s simple. Just use the following syntax:
cp yourfile.txt yourfile(2).txt
Sometimes we want to copy files to different folder, so u can follow this syntax;
cp /home/fivem/yourfile.txt /home/test/
Make sure to insert the name of the destination file before running cp. If you provide two file names, cp will copy the content of the source file into the destination file When the destination file doesn’t exist, that command will create a new file.
8. “mv” Command #
The mv command is used to change the location of a file or folder. This can be done in a number of ways, and includes moving files or folders within the same directory, moving one between directories, or renaming one in place. Mv command syntax varies depending on which type of move is being made.
mv [source] [destination]
For example. if you want to move yourfile.txt from /home/Fivem to /home/test, then the command should be;
mv /home/Fivem/yourfile.txt /home/test
9. “grep” Command #
The grep can be useful when you’re trying to find a string inside files, like;
The above command would search for “line” in the file named “info.txt”. What’s great, the command will print the entire line that contains the matched text
grep ‘line’ info.txt
10. “history” Command #
This is a command that allows you to limit the last used commands, this option is found under ‘Last Used Commands.’ Here are some examples of what the limited results might look like:
11. “clear” Command #
Clearing all text from the terminal screen can be done with a simple catch-all command, as this is something that’s been around since the original PC computer was created.
You can simply type, syntax command is “clear“.
12. “tar” Command #
Tar is a very popular command line tool used to access files in the .tar.gz format. The software binary packages offered by companies as products are usually compressed into this format because they are universally accepted, making tar an ideal tool for extracting them on demand.
Archive a folder in .tar.gz format by typing:
tar cvzf ArchiveName.tar.gz /path/to/directory
When you have .tar.gz file, need to extract the file to see the files or folders containing. so use this command lines;
tar xvzf FileName.tar.gz
13. “vi/nano” Command #
Vi and Nano are two popular text editors you can use in the command line. It is simply used to edit a file also you can create new file using this command.
vi [filename] or nano [filename]
14. “wget” Command #
HTTP downloads are very common and using wget to perform these is straightforward. For example, when fetching a file from the web, we would use:
To download multiple files, it’s best to download them all in one go with tools like wget or curl. You just need to give the tool a URL you want it to download and it will append every other link after that into a file.
wget -i downloads.txt
This command will apply to all files in the downloads.txt directory. I usually use backslashes instead of forward slashes because they are much easier to type on a number of keyboards
15. “du” Command #
This command to used to check disk usage of the files or folders in any specified directory.
du [directory path]
Unfortunately, the summary will show disk block numbers instead of bytes, kilobytes, and megabytes. To view it in a human-readable format, you need to use | -h after du command:
du -h /home
This will make it easier for readers to understand.