Mastering Ubuntu: Essential Command Line Tricks

Ubuntu Commands Techhyme

Ubuntu, a popular Linux distribution, provides a powerful command-line interface that allows users to interact with their system efficiently. Whether you’re a beginner or an experienced user, understanding essential Ubuntu commands can significantly enhance your productivity and control over the operating system.

In this article, we will explore some of the most useful Ubuntu commands for everyday tasks.

  1. Copying Files
  2. Checking Free Disk Space
  3. Checking Firewall Status
  4. Allowing External IP to Access a Port
  5. Transferring Files using SCP
  6. Uploading Files using SCP
  7. Gaining Root Access
  8. Monitoring Virtual Memory Usage
  9. Displaying Server IP
  10. Listing Processes on a Specific Port
  11. Viewing Service Logs
  12. Resizing a Volume
  13. Searching for Processes
  14. Terminating a Process

1. Copying Files
Copying files between your local machine and a remote server is a common task. The `scp` command comes to the rescue in such situations. To copy a file from your local machine to a server, use the following command:

scp /path/to/file user@server:/path/to/destination

2. Checking Free Disk Space
Keeping track of available disk space is crucial for maintaining a healthy system. The `df` command displays the disk usage statistics in human-readable format:

df -h

3. Checking Firewall Status
Ubuntu uses Uncomplicated Firewall (ufw) to manage firewall rules. To check the status of the firewall, use:

sudo ufw status

4. Allowing External IP to Access a Port
To enable access to a specific port from a remote IP address, use the `ufw` command as follows:

sudo ufw allow from remote_IP_address to any port 3306

5. Transferring Files using SCP
Besides copying files from local to remote and vice versa, you can also download files from a remote server using `scp`:

scp user@remote_host:remote_file local_file

6. Uploading Files using SCP
To upload a file from your local machine to a remote server, use:

scp local_file user@remote_host:remote_file

7. Gaining Root Access
Sometimes you need elevated privileges to perform certain operations. You can switch to the root user with the `sudo -s` command:

sudo -s

8. Monitoring Virtual Memory Usage
You can view the current virtual memory usage of a specific Linux process using the `/proc` filesystem:

cat /proc/<process_id>/maps

9. Displaying Server IP
To check the IP address of your server, you can use the `ip` command:

ip r

10. Listing Processes on a Specific Port
To see which processes are running on a specific port, you can use the `lsof` command:

lsof -i :9000

11. Viewing Service Logs
To check the last 100 logs for a specific service, you can use the `journalctl` command:

journalctl -u minio.service -n 100 --no-pager

12. Resizing a Volume
If you need to resize a volume, you can use the `resize2fs` command:

sudo resize2fs /dev/disk/by-id/scsi-0DO_example

13. Searching for Processes
To search for processes running on your system, you can use the `ps` command along with `grep`:

ps -ax | grep myprocessname

14. Terminating a Process
If a process becomes unresponsive and needs to be forcibly terminated, use the `kill` command:

kill -9 PROCESS_ID

These Ubuntu commands are just the tip of the iceberg, but they cover some of the most common tasks you’ll encounter. By familiarizing yourself with these commands, you’ll gain greater control over your Ubuntu system and be better equipped to handle various administrative and development tasks.

Happy command-lining!

You may also like:

Related Posts

Leave a Reply