Unlock Your Linux Potential: 10 Essential Commands Every Developer Needs to Know
3 min read
If you don't know how to use commands or have never used them before, you must use the Terminal program on your computer.
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
- cd Change Directory
Use this to switch the current working directory.
- pwd (Print Working Directory)
Use this to see the current working directory
- mkdir (Make a directory)
Use this to Create a new directory at the path
- ls (List)
Use this to list the items in a 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.
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)
Use this to copy files and folders from one path to another and have multiple copies of the file.
cp source destination
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.
mv source destination
mv my-file.txt new-file.txt
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.
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.
Make sure the firewall of the remote machine allows external traffic for the ssh command on the port you specified.
Use this to edit files on UNIX systems.
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
Use this to transfer large files securely between computers.
It requires authentication.
- 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.
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:-
That's the end. For any questions, kindly leave them in the comment section or DM me via Twitter @davidofug