As a software developer, being efficient with the Linux command line is a must. Ubuntu, being one of the most popular Linux distributions, offers a robust set of built-in commands to help developers quickly navigate files and systems, install packages, monitor processes, and much more.

Here are 25 of the most useful Ubuntu commands for software developers:

1. pwd – Print working directory

The pwd command prints the current working directory you are in. This helps orient you when working across multiple directories:

user@ubuntu:~$ pwd
/home/user

2. ls – List directory contents

To see the files and folders in your current directory, use ls. You can pass various flags to control the output:

user@ubuntu:~$ ls 
Documents  Downloads  Music  Pictures

user@ubuntu:~$ ls -l
total 12
drwxr-xr-x 2 user user 4096 Feb 10 13:46 Documents
drwxr-xr-x 3 user user 4096 Feb 11 15:32 Downloads
drwxr-xr-x 2 user user 4096 Feb 9 11:58 Music
drwxr-xr-x 2 user user 4096 Feb 9 11:58 Pictures

3. cd – Change directory

To navigate between directories, use cd. For example:

user@ubuntu:~$ cd Documents/
user@ubuntu:~/Documents$

Use cd .. to go up one directory.

4. mkdir – Make directory

To create a new directory, use mkdir:

user@ubuntu:~/Documents$ mkdir projects
user@ubuntu:~/Documents$ ls
projects

5. touch – Create empty file

The touch command creates a new empty file. This is useful when you need an empty file to start writing code:

user@ubuntu:~$ touch app.py
user@ubuntu:~$ ls
app.py

6. cat – View file contents

To quickly view a file‘s contents without opening it in an editor, use cat:

user@ubuntu:~$ cat app.py
print("Hello world!")

7. cp – Copy files

To copy files or folders, use the cp command. Here we copy app.py to the Documents folder:

user@ubuntu:~$ cp app.py ~/Documents

Use flags like -r for recursive copy.

8. mv – Move/rename files

The mv command lets you move or rename files. To rename app.py to main.py:

user@ubuntu:~$ mv app.py main.py

To move it to Documents:

user@ubuntu:~$ mv main.py ~/Documents

9. rm – Remove files

Deleting files is done with rm. Be very careful, as deleted files can‘t be recovered!

user@ubuntu:~$ rm main.py

Use flags like -r for recursive delete.

10. sudo – Run commands as superuser

Many commands like installing packages require admin access, done with sudo. It prompts for your user password:

user@ubuntu:~$ sudo apt update
[sudo] password for user: 

11. apt – Install/remove packages

Ubuntu‘spackage manager apt lets you install new packages. Updating the index fetches the latest packages:

user@ubuntu:~$ sudo apt update
user@ubuntu:~$ sudo apt install git

Use remove instead to uninstall packages.

12. systemctl – Manage services

To check the status, start, restart services:

user@ubuntu:~$ sudo systemctl status apache2
user@ubuntu:~$ sudo systemctl start apache2

13. ps – View running processes

To see processes running in the background, use ps:

user@ubuntu:~$ ps
  PID TTY          TIME CMD
    1 ?        00:00:02 systemd
    2 ?        00:00:00 kthreadd
    3 ?        00:00:00 rcu_gp
    ...

14. kill – Terminate processes

To forcibly quit processes, get the PID (process ID) from ps and kill it:

user@ubuntu:~$ kill 1234

15. grep – Search files by keyword

You can search for files containing specific keywords using grep:

user@ubuntu:~$ grep "hello" ~/Documents/*

This searches all files recursively in Documents containing "hello".

16. find – Find files by name

To find a file by name when you‘re not sure where it is, use find:

user@ubuntu:~$ find . -name "settings.py"
./Projects/myapp/settings.py

17. tar – Archive files

To compress files into a tarball archive, use tar:

user@ubuntu:~$ tar -cvf myproject.tar ~/Projects/myproject

Use flags like z to also gzip compress the archive.

18. chmod – Change file permissions

To modify a file or folder‘s permissions, use chmod:

user@ubuntu:~$ chmod 600 secret.txt
user@ubuntu:~$ chmod -R 750 myfolder/

19. ssh – Remote login

To connect to and manage remote servers, ssh is indispensable:

user@local:~$ ssh user@remote-server.com

Public key authentication helps secure remote access.

20. df – See disk space usage

Wondering why your disk is full? Use df to view disk space usage for mounted disks:

user@ubuntu:~$ df
Filesystem   1K-blocks     Used Available Use% Mounted on
udev            249544        0    249544   0% /dev
tmpfs            51796     1744     50052   4% /run
/dev/sda1      15719556 14722164         0 100% /

21. du – Disk usage by file

In addition to disk space usage by mount point, view usage by file and folder with du:

user@ubuntu:~$ du -sh *
4.0K    Documents
8.5M    Downloads 
4.0K    Music
16K     Pictures

22. top – Process activity monitor

Constantly monitor active processes ordered by resource usage using top:

user@ubuntu:~$ top

PID USER      PR  NI    VIRT    RES    SHR S  %CPU  %MEM     TIME+ COMMAND          
4114 root      20   0  102296   6176   5016 S   5.6   0.1   0:06.77 Xorg

  1 root      20   0   44312   3476   2976 S   0.0   0.1   0:03.47 systemd
13751 user     20   0  848932 142180 154764 S   0.0   4.3   0:07.02 Web Content

Hit ctrl+C to exit out.

23. history – Command history

View your previously used commands with history:

user@ubuntu:~$ history
  1  ls
  2  cd Documents/
  3  touch app.py
  4  python3 app.py
  5  sudo apt update
  ...

Rerun previous commands by index with !n.

24. man – Help manual

When in doubt, refer command help manuals with man. Shows usage, flags, and examples:

user@ubuntu:~$ man ps

25. uname – System info

See Linux host details like kernel version, hardware architecture, etc with uname:

er@ubuntu:~$ uname -a 
Linux ubuntu 5.4.0-105-generic x86_64 x86_64 x86_64 GNU/Linux

So those are 25 must-know Ubuntu commands for developers to help boost efficiency! The terminal may seem intimidating as a new Linux user, but mastering these basic commands will enhance your skills.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *