Unlock Your Linux Potential: 10 Essential Commands Every Developer Needs to Know

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

  1. cd Change Directory

Use this to switch the current working directory.

Example

cd path/to/folder/
  1. pwd (Print Working Directory)

Use this to see the current working directory

Example

pwd
  1. mkdir (Make a directory)

Use this to Create a new directory at the path

Example

mkdir sample-folder
  1. ls (List)

Use this to list the items in a directory.

Examples

  1.   ls /path/to/directory
    
  2.   ls -al /path/to/directory (This option will show you more details such as permissions)
    
  3. rm (Remove a directory)

Use this to delete a file or directory.

Examples:

  1.   rm path/to/file
    
  2.   rm -r path/to/directory (Will remove the directory and its sub contents)
    
  3.   rm -f path/to/file (will remove the file without prompting you to confirm)
    
  4. 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
  1. 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
  1. 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

  1.   ssh username@ip
    
  2.   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.

  1. 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

  1. scp

Use this to transfer large files securely between computers.

It requires authentication.

Examples

  1. Upload file
scp file.txt username@hostname:/remote/directory/
  1. Download file
scp username@hostname:/remote/directory/file.txt .
  1. 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