Home Beginner's Guide 25 essential commands for new Ubuntu Server users

25 essential commands for new Ubuntu Server users

This article breaks down 25 beginner commands, each explained with its function, to help you get started. By mastering these commands, you'll be on your way to becoming an adept Ubuntu Server user.

by Arun Kumar
25 essential commands for new ubuntu server users

Ubuntu, which is known for being one of the most user-friendly distributions of Linux, has gained a lot of popularity lately. Especially for those who are new to servers, Ubuntu Server has become the preferred choice. However, starting with Ubuntu Server can be intimidating for beginners. But don’t worry! With the right commands, you’ll be able to learn and get comfortable in no time.

I still remember my first experience with Ubuntu Server. The vastness of the system was overwhelming and left me feeling lost. However, with practice and research, I became proficient and confident in my abilities. In this article, I will be sharing 25 essential commands that are a must-know for beginners. I wish I had known these commands earlier on!

No default Graphical User Interface (GUI) in Ubuntu Server

If you’re new to the Ubuntu Server world, you might wonder, “Why should I bother with the command line when there are graphical interfaces available?” It’s a valid question.

Ubuntu Server editions do not come with a default graphical user interface. This is done to conserve system resources and maintain the highest level of efficiency and stability. Servers often work in environments where performance and uptime are critical. Having a GUI can introduce unnecessary overhead, which can be avoided by eliminating these graphical components. By doing so, the system can dedicate more of its resources to its core functionalities.

Moreover, not having a GUI encourages administrators to engage with the command line, which allows them to harness its full power and versatility. Although it’s technically possible to install a GUI on Ubuntu Server, many experienced administrators avoid it to keep their servers lean and efficient.

A beginner’s guide to 25 essential Ubuntu Server commands

1. Navigating the Directory: ‘pwd’ and ‘ls’

Knowing where you are is the first step.

Command: pwd

What it does: Displays the path of the current directory.

Sample output:

/home/fosslinux

It’s like asking, “Where am I right now?” in the vast maze of directories. Once you know where you are, you would want to see what’s around you.

Command: ls

What it does: Lists all the files and directories in the current folder.

Sample output:

Documents  Pictures  Downloads  Music

These were lifesavers when I first began. I cannot stress enough how often I used them (and still do).

2. Moving Around: ‘cd’

Now that you know where you are and what’s around, you’ll need to navigate.

Command: cd [directory_name]

What it does: Changes the current directory to the one specified.

Sample output:

cd Documents
pwd
/home/fosslinux/Documents

3. Creating and Removing Directories: ‘mkdir’ and ‘rmdir’

Creating a space for your files is a common task.

Command: mkdir [directory_name]

What it does: Creates a new directory with the specified name.

Sample output:

mkdir NewFolder
ls
Documents  Pictures  Downloads  Music  NewFolder

But sometimes, we create directories by mistake or don’t need them anymore. Here’s how you get rid of them.

Command: rmdir [directory_name]

What it does: Removes the specified directory.

Sample output:

rmdir NewFolder
ls
Documents  Pictures  Downloads  Music

4. Creating and Removing Files: ‘touch’ and ‘rm’

You won’t always be dealing with directories. Files come into play, and here’s how you handle them.

Command: touch [file_name]

What it does: Creates a new empty file.

Sample output:

touch example.txt
ls
Documents  Pictures  Downloads  Music  example.txt

And for those times you accidentally named a file “exapmle.txt” instead of “example.txt” (guilty as charged), you’ll want to remove it.

Command: rm [file_name]

What it does: Deletes the specified file.

Sample output:

rm example.txt
ls
Documents  Pictures  Downloads  Music

5. Viewing File Contents: ‘cat’

I have a soft corner for ‘cat’, primarily because of its name. But jokes apart, it’s invaluable!

Command: cat [file_name]

What it does: Displays the content of the specified file.

Sample output:

echo "This is a sample text." > fosslinux.txt
cat fosslinux.txt
This is a sample text.

6. Searching for Files: ‘find’

Looking for a file can be like searching for a needle in a haystack. Thankfully, ‘find’ makes it easier.

Command: find [path] -name [file_name]

What it does: Searches for a file in the specified path.

Sample output:

find /home/fosslinux -name sample.txt
/home/fosslinux/sample.txt

7. Displaying System Information: ‘uname’

Curious about your system? ‘uname’ is your friend.

Command: uname -a

What it does: Shows detailed system information.

Sample output:

Linux ubuntu-server 5.4.0-65-generic #73-Ubuntu SMP Mon Jan 18 17:25:17 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

8. Monitoring Processes: ‘top’

One of the first commands I was advised to learn was ‘top’. It’s like the Task Manager but in the terminal.

Command: top

What it does: Displays active processes and system performance metrics.

Sample output:

Tasks:  95 total,   1 running,  94 sleeping,   0 stopped,   0 zombie
%Cpu(s):  5.7 us,  3.4 sy,  0.0 ni, 90.6 id,  0.3 wa,  0.0 hi,  0.0 si,  0.0 st
MiB Mem :   2048.0 total,   1693.1 free,    159.7 used,    195.2 buff/cache
MiB Swap:      0.0 total,      0.0 free,      0.0 used.   1821.3 avail Mem 

9. Networking Check: ‘ifconfig’

Networking issues can be tricky. ‘ifconfig’ gives you a snapshot of your network configurations.

Command: ifconfig

What it does: Displays network configuration.

Sample output:

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.1.10  netmask 255.255.255.0  broadcast 192.168.1.255
        inet6 fe80::20c:29ff:fe0c:1122  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:0c:11:22  txqueuelen 1000  (Ethernet)

10. Reboot and Shutdown: ‘reboot’ and ‘shutdown’

Finally, turning things off safely is as essential as any other task.

Command: reboot

What it does: Reboots the system immediately.

And when you’re done for the day…

Command: shutdown -h now

What it does: Shuts down the system immediately.

11. Copying files: ‘cp’

Making copies of files can be crucial, especially when modifying configurations.

Command: cp [source_file] [destination_directory_or_file]

What it does: Copies a file to a specified destination.

Sample output:

touch file1.txt
cp file1.txt file2.txt
ls
file1.txt  file2.txt

12. Moving or renaming files: ‘mv’

This command does double-duty – both moving and renaming.

Command: mv [source] [destination]

What it does: Moves or renames files or directories.

Sample output:

mv file2.txt newfile.txt
ls
file1.txt  newfile.txt

13. Checking disk usage: ‘df’

Space concerns? Check your disk usage.

Command: df -h

What it does: Displays disk space usage in a human-readable format.

Sample output:

Filesystem      Size  Used Avail Use% Mounted on
/dev/sda1       30G   7.8G  21G  28% /

14. Checking directory size: ‘du’

Similar to ‘df’, but for directories.

Command: du -sh [directory_name]

What it does: Displays the size of the specified directory.

Sample output:

du -sh /home/fosslinux/Documents
256M    /home/fosslinux/Documents

15. Changing file permissions: ‘chmod’

A crucial command for managing file permissions.

Command: chmod [permissions] [file_name]

What it does: Changes file permissions.

Sample output:

chmod 755 script.sh
ls -l script.sh
-rwxr-xr-x 1 username username 0 Oct 13 10:00 script.sh

16. Changing file ownership: ‘chown’

Equally important is setting the correct file ownership.

Command: chown [user:group] [file_name]

What it does: Changes file ownership.

Sample output:

chown username:username file1.txt

17. Zipping files: ‘zip’

For compressing and archiving files.

Command: zip [archive_name.zip] [file_name]

What it does: Compresses files into a .zip archive.

Sample output:

zip archive.zip file1.txt
  adding: file1.txt (stored 0%)

18. Unzipping files: ‘unzip’

The counterpart to ‘zip’.

Command: unzip [archive_name.zip]

What it does: Extracts files from a .zip archive.

Sample output:

unzip archive.zip
Archive:  archive.zip
  inflating: file1.txt

19. Searching inside files: ‘grep’

A powerful searching tool I use almost daily.

Command: grep [search_term] [file_name]

What it does: Searches for a specific term inside files.

Sample output:

echo "Hello World" > file.txt
grep "Hello" file.txt
Hello World

20. Displaying manual pages: ‘man’

When in doubt, consult the manual!

Command: man [command_name]

What it does: Shows the manual page for a command.

Sample output:

man ls
LS(1)                           User Commands                          LS(1)
...

21. Editing files: ‘nano’

A beginner-friendly file editor.

Command: nano [file_name]

What it does: Opens a file in the nano editor.

Sample output:

nano file.txt
... [opens the nano editor interface]

22. Updating system packages: ‘sudo apt update’

Keeping the system up-to-date is fundamental.

Command: sudo apt update

What it does: Fetches the list of available updates.

Sample output:

Hit:1 http://archive.ubuntu.com/ubuntu focal InRelease
... [truncated for brevity]

23. Installing new packages: ‘sudo apt install’

When you need new software.

Command: sudo apt install [package_name]

What it does: Installs a new package.

Sample output:

sudo apt install curl
Reading package lists... Done
...

24. Viewing command history: ‘history’

Ever wonder what commands you entered earlier?

Command: history

What it does: Displays a list of previously entered commands.

Sample output:

  1  ls
  2  pwd
  3  cd /home
...

25. Network Ping: ‘ping’

Check if a server or website is reachable.

Command: ping [website_or_IP]

What it does: Sends packets to the specified address and receives a response.

Sample output:

ping google.com
PING google.com (216.58.217.142) 56(84) bytes of data.
64 bytes from iad23s43-in-f14.1e100.net (216.58.217.142): icmp_seq=1 ttl=53 time=28.7 ms
...

Summary for quick reference

Command Function Example
ls List directory contents ls -l
pwd Print working directory pwd
cd Change directory cd /home
mkdir Create a directory mkdir new_directory
rmdir Remove a directory rmdir new_directory
touch Create an empty file touch file.txt
cat Display file content cat file.txt
rm Remove files or directories rm file.txt
ifconfig or ip a Display network interfaces ifconfig
sudo Execute command as superuser sudo apt update
cp Copy files cp source.txt dest.txt
mv Move or rename files mv old.txt new.txt
df Display disk space usage df -h
du Display directory size du -sh /home
chmod Change file permissions chmod 755 file.txt
chown Change file ownership chown user:group file.txt
zip Compress files into zip zip archive.zip file.txt
unzip Extract files from zip unzip archive.zip
grep Search inside files grep "term" file.txt
man Display manual pages man ls
nano Edit files nano file.txt
sudo apt update Update system packages sudo apt update
sudo apt install Install new packages sudo apt install curl
history View command history history
ping Network ping ping google.com

Conclusion

Starting with Ubuntu Server may seem like a daunting task, but with these essential commands, you can navigate the system with ease. These basic commands are useful even for advanced users. Take your time, practice these commands, and before you know it, you’ll be proficient in using Ubuntu Server like a pro! Let’s start the journey towards mastering Ubuntu Server together.

You may also like

Leave a Comment

fl_logo_v3_footer

ENHANCE YOUR LINUX EXPERIENCE.



FOSS Linux is a leading resource for Linux enthusiasts and professionals alike. With a focus on providing the best Linux tutorials, open-source apps, news, and reviews written by team of expert authors. FOSS Linux is the go-to source for all things Linux.

Whether you’re a beginner or an experienced user, FOSS Linux has something for everyone.

Follow Us

Subscribe

©2016-2023 FOSS LINUX

A PART OF VIBRANT LEAF MEDIA COMPANY.

ALL RIGHTS RESERVED.

“Linux” is the registered trademark by Linus Torvalds in the U.S. and other countries.