25 Super Useful Ubuntu Commands for Beginners

·

5 min read

Ubuntu is one of the most user-friendly Linux distributions. While it’s tempting to rely solely on GUI tools, there’s no denying that an efficient command-line trick might get things done quicker. Here are 25 commands to make your Ubuntu Terminal experience a really really better.

1. Navigating Your File System Like a Pro

When you first start with Ubuntu, navigating the file system can feel a bit daunting. But with the cd command, you can jump between directories with ease. If you’re ever lost, simply type pwd to print your current working directory. To quickly jump back to your home folder, use cd ~.

2. Listing Files and Directories

To see what’s in your current directory, ls is your best friend. Add the -l flag for more detailed information, like file permissions and modification dates. Want to see hidden files as well? Try ls -a.

3. Getting Help

If you ever find yourself unsure about what a command does, man is your go-to. It opens the manual for any command, providing useful details on its options and syntax. For example, man ls will show you everything you need to know about the ls command.

4. Creating Files and Directories

Creating files and directories is a breeze with touch for files and mkdir for directories. Try touch myfile.txt to create a new empty text file, or mkdir myfolder to create a new directory.

5. Copying and Moving Files

Copying files is simple with cp, while mv is used for both moving and renaming files. For example, cp file.txt backup.txt will create a copy of file.txt, while mv oldname.txt newname.txt renames the file.

6. Deleting Files and Directories

When it’s time to clean up, use rm to remove files. Want to delete a directory and all of its contents? Add the -r flag: rm -r myfolder. Just be careful—once it’s gone, it’s gone.

7. Searching for Files

Need to find a file or folder? find is an incredibly powerful search tool. Use it like this: find / -name "filename", and Ubuntu will search from the root directory for anything named filename.

8. Installing Software

One of Ubuntu’s best features is its package management system. To install software, use sudo apt install <package-name>. Whether it’s a browser, editor, or system utility, this is the way to go.

9. Updating Your System

Keep your system up-to-date with the sudo apt update command, which checks for the latest available package versions. After updating, sudo apt upgrade will install those updates and ensure everything is running smoothly.

10. Removing Software

If you no longer need a program, you can easily remove it with sudo apt remove <package-name>. If you want to also remove any leftover configuration files, use sudo apt purge <package-name>.

11. Checking Disk Usage

To see how much space is being used by your files and directories, du -sh is a quick and easy way to check. Want to check the space on your hard drive? df -h will show you disk usage in a human-readable format.

12. Checking System Resource Usage

The top command displays system resource usage, like CPU and memory usage, in real-time. For a more advanced view, use htop, which provides a colourful, interactive interface.

13. Viewing File Contents

To read the contents of a file, you can use cat for quick viewing, or less for a more navigable experience. With less, you can scroll through a file, search for keywords, and more.

14. Editing Files in the Terminal

Sometimes you don’t need to open a full-blown GUI text editor. For quick file edits in the Terminal, nano or vim are your best bets. nano is the easier option, while vim offers more advanced functionality once you get the hang of it.

15. Checking System Information

Need to know more about your system? uname -a will display general system information, while lscpu reveals details about your processor. For memory information, free -h is the command you want.

16. Finding Processes

If you need to check on processes that are running, ps aux will list them all. For more interactive management, use top or htop to watch processes in real-time.

17. Killing Processes

Sometimes, things get stuck and need to be killed off. To stop a process, you can use kill followed by the process ID (PID). If a process won’t budge, kill -9 <PID> will forcefully terminate it.

18. Changing File Permissions

Ubuntu has a detailed system of file permissions. To change them, chmod is your command. For instance, chmod 755 myfile.txt gives read, write, and execute permissions to the owner, and read/execute permissions to others.

19. Redirecting Output

Sometimes you want to save output from a command. You can do this by redirecting it with > for a new file or >> to append it. For example, ls > files.txt will save the list of files to files.txt.

20. Piping Commands

Want to send the output of one command to another? | (pipe) is how it’s done. For example, ls | less sends the output of ls to less, letting you scroll through it.

21. Running Commands in the Background

Need to run a process in the background? Add & to the end of your command. For example, longprocess & runs the process without blocking your Terminal.

22. Switching Between Users

If you need to switch users in the middle of a session, su <username> lets you do that without logging out. You’ll need the password for that user, of course.

23. Viewing Network Information

To check your IP address, use ip a. If you need more detailed network information, netstat -tuln displays active connections and listening ports.

24. Getting Weather Information

Want to know if it’s a good day for a walk? Use curl wttr.in to get a simple weather report in your Terminal. It’s a quick and easy way to check the forecast without opening your browser.

25. Shutting Down or Restarting

Finally, when you’re done, shut down or restart your machine with sudo shutdown -h now or sudo reboot. They’ll gracefully shut down or restart your system, perfect for a clean exit after a hard day’s work.

These 25 commands will have you feeling like a Linux pro in no time. They’re simple, super, and will help develop a solid foundation to work with Ubuntu in the Terminal. Use them often, discover just how much faster and efficient your Ubuntu experience can be.