Mastering your Linux commands with an Ubuntu Operating System.


In an Ubuntu OS environment, writing Linux commands relies heavily on the command-line interface (CLI) for interacting with the system as a powerful and versatile operating system. While seemingly daunting at first, understanding basic Linux commands empowers users to efficiently manage files, navigate directories, and perform various system-related tasks. Furthermore, using Linux commands in the command-line interface (CLI).
The Command Line Interface (CLI) and its structure: Linux offers a powerful CLI, also known as the terminal or shell. It also allows users to interact with the system by typing text-based commands and provides greater control and efficiency compared to graphical user interfaces (GUIs).
command: The action you want to perform (e.g., ls to list files).
options: Modify the behavior of the command (e.g., ls, -l for a detailed list).
arguments: The inputs the command operates on (e.g., a file or directory name).
i. Administrative Rights: The sudo command is the primary way to execute commands with administrative (superuser or root user) privileges. It allows authorized users to temporarily elevate their permissions to perform tasks that require root access, like installing software, managing users, or modifying system files. Where “su” stands for "substitute user" or "switch user," on typing “sudo su,” it will request a password to verify if you are the root user; while typing your password, it will be invisible, and thereafter, having been successfully authenticated, your command prompt will change (typically from $ to #), indicating that you are now operating as the root user, as captured below.
ii. Package management: These commands help users install, update, remove, and manage software packages on their systems. Different Linux distributions use different package managers, such as apt update (Debian, Ubuntu), dnf (Fedora), and pacman (Arch Linux), which are common commands for updating package lists, installing, upgrading, and removing packages. The apt update, when typed and run, will update package lists for upgrades, and when apt upgrade is typed, it will install the newest versions of all packages currently installed on the system, and on listing, it will list all packages that have available updates.
apt update
- making sure the latest version of the package is running with the OS.
iii. Make Directory (mkdir): This command in Linux is used to create new directories (folders). The basic syntax is mkdir (directory_name). E.g., mkdir my_directory will create a directory named "my_directory" in the current location. Multiple directories can also be created at once by listing their names separated by spaces. With a subdirectory having been created.
ls
is to list the content of the directory.
mkdir
is to make a directory.
iv. Change Directory (cd): This command in Linux is used to change the current working directory. It's a fundamental command for navigating the file system. You can use it to move to specific directories, return to the home directory, or move up or back in the directory tree as captured below. cd
- directory location or change directory.
v. Create Files: In Linux, several commands can be used to create files. The touch command is commonly used to create empty files (e.g., index.html). For creating files with content, the echo or cat commands with redirection are useful. Text editors like nano or vim can also be used to create and edit files.
touch
- is to create a file.
vi or vim
- is to open a text editor.
The ability to type and edit in the vim
environment is to type the letter “i” as shown below.
After typing and editing in the vim
environment, we can use the following code.
To exit, press the "esc" button on your pc keyboard and type":wq" and press "enter” and come out of the environment.
Thereafter, to view my text content from file created as shown below.
cat
- to display a read-only text content on the CLI.
This command displays the entire contents of the file, recommended for small files.
echo
- to edit the text content in the file from the CLI.
history
- This lists the history of the command used per session.
This command helps you keep track of the commands you’ve executed in the terminal session, which can be useful for recalling complex command sequences or troubleshooting issues.
Conclusion: The ability to understand basic Linux commands is fundamental for effectively interacting with the system running with an Ubuntu operating system. The CLI provides a powerful and efficient way to manage files, navigate directories, and perform various tasks. By learning the basic command structure and utilizing tools like manual and
--help
, users can quickly build their command-line proficiency.The output below shows a brief description of the Linux command and its meaning, which was captured from the folder created.
Subscribe to my newsletter
Read articles from Gabriel Aboiraor directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
