Unlock Your Linux Potential: 10 Essential Commands Every Developer Needs to Know
Table of contents
If you don't know how to use commands or have never used them before, you must use the Terminal program on your computer.
Introduction
Type the command on the terminal program. Then press Enter on your keyboard to see the output.
Command output can be modified by flags(options)
The word directory also refers to a folder
Commands are case-sensitive
Commands may require more user privileges
The commands
- cd Change Directory
Use this to switch the current working directory.
Example
cd path/to/folder/
- pwd (Print Working Directory)
Use this to see the current working directory
Example
pwd
- mkdir (Make a directory)
Use this to Create a new directory at the path
Example
mkdir sample-folder
- ls (List)
Use this to list the items in a directory.
Examples
ls /path/to/directory
ls -al /path/to/directory (This option will show you more details such as permissions)
rm (Remove a directory)
Use this to delete a file or directory.
Examples:
rm path/to/file
rm -r path/to/directory (Will remove the directory and its sub contents)
rm -f path/to/file (will remove the file without prompting you to confirm)
cp (Copy)
Use this to copy files and folders from one path to another and have multiple copies of the file.
Quickstart Syntax:
cp source destination
Example
cp path/to/source path/to/destination
- mv (Move)
Use this to move files from one path to another.
Since this one doesn't leave you with multiple copies of the file, it can be referred to as Rename command.
Quickstart Syntax:
mv source destination
Example
mv my-file.txt new-file.txt
- ssh
Use this to log in to other UNIX systems on the internet and your local network.
This command requires you to provide a password for the user on the machine you're connecting to.
Examples
ssh username@ip
ssh username@hostname -p 2223
The -p is a flag that modifies the ssh command so that it can accept a custom port number.
Usually, servers are configured with custom ssh port numbers and the default 22 port will not work. In that case, you need to know the custom port number to connect to the server or computer you want to connect to.
Troubleshooting
Make sure the firewall of the remote machine allows external traffic for the ssh command on the port you specified.
- nano
Use this to edit files on UNIX systems.
Example
nano myfile.txt
This will create myfile.txt if it doesn't exist and open it for editing.
Otherwise, it will open it for editing.
Press Control + O and Enter on the keyboard to save changes. Then Control + X to exit the nano
- scp
Use this to transfer large files securely between computers.
It requires authentication.
Examples
- Upload file
scp file.txt username@hostname:/remote/directory/
- Download file
scp username@hostname:/remote/directory/file.txt .
- Transfer directory
scp -r /path/to/local/directory/ username@remotehost:/path/to/remote/directory/
Note: -r in the above command. It is a flag that changes the scp command so that all the files in the directory can be uploaded.
Conclusion
As you can see, commands can help you in many ways. Whether you want to manipulate files, and directories, or perform network tasks. Learning commands can also be helpful to automate certain tasks.
The 10 Commands we've looked at are:-
1. cd
2. pwd
3. mkdir
4. ls
5. rm
6. cp
7. mv
8. ssh
9. nano
10. scp
That's the end. For any questions, kindly leave them in the comment section or DM me via Twitter @davidofug