Linux and Linux Commands

Ebube UmeobiEbube Umeobi
4 min read

This article is mostly for my retention of Linux commands :) I hope it helps you too!

Introduction to Linux

Linux is a command line interface that enables you to effectively work on your Linux pc.

Linux is also a powerful, open-source operating system based on Unix. It is used for servers, development environments, cloud computing, and embedded systems. It offers stability, security, and flexibility, making it a preferred choice for system administrators and DevOps engineers.
Interaction in Linux is carried out by typing commands into the command line interface and receiving a response.

Some Key Features of Linux:

1. Open-source: Linux is free to use.

2. Multi-user: Supports multiple users at the same time.

3. Multitasking: Multiple processes can be run at the same time.

4. Security: Strong user permissions and security features.

5. Flexibility: Linux is flexible by customizing through configurations and scripting.

6. Networking: There are built-in networking capabilities in Linux.

Common Linux Commands

Linux commands allow users to interact with the system through the terminal or command line interface (CLI). Below are some Linux commands and their functionality.

File and Directory Management

ls => Lists files in a directory

cd <directory> => Changes the current directory

pwd => Prints the current working directory

mkdir <directoryname> => Creates a new directory

rmdir <directoryname> => Removes an empty directory

rm <filename> => Deletes a file

rm -r <directoryname> => Deletes a directory and its contents

cp <source file/directory> <destination file/directory> => Copies a file or directory

mv <source file/directory> <destination file/directory> => Moves or renames a file

File Viewing and Editing

cat <filename> => Displays file contents

less <filename> => Views file contents page by page

head <filename> => Shows the first 10 lines of a file

tail <filename> => Shows the last 10 lines of a file

nano <filename> => Opens a file in the nano text editor

vim <filename> => Opens a file in the vim text editor

User Management

whoami => Displays the current user

who => Shows logged-in users

id => Displays user ID (UID) and group ID (GID)

adduser <username> => Creates a new user

passwd <username> => Changes a user's password

deluser <username> => Deletes a user

groupadd <groupname> => Creates a new group

usermod -aG <group> <user> => Adds a user to a group

groups <username> => Displays groups a user belongs to

Process Management

ps => Displays active processes

top => Shows real-time process information

kill <PID> => Kills a process by its PID

pkill <process_name> => Kills a process by name

htop => Interactive process viewer (if installed)

File Permissions and Ownership

chmod <permissions> <file> => Changes file permissions

chown <user>:<group> <file> => Changes file ownership

ls -l => Displays detailed file permissions

Networking

ping <host> => Sends ICMP echo requests to a host

ifconfig => Displays network interfaces (deprecated, use ip)

ip a => Shows IP addresses and interfaces

netstat -tulnp => Displays open network connections (netstat means Network Statistics)

curl <URL> => Fetches data from a URL

Package Management

Debian-based Systems (Ubuntu, Debian)

apt update => Updates package lists

apt upgrade => Upgrades installed packages
apt install <package> => Installs a package

apt remove <package> => Removes a package

Red Hat-based Systems (CentOS, Fedora)

yum update => Updates package lists

yum install <package> => Installs a package

yum remove <package> => Removes a package

Disk and System Monitoring

df -h => Shows disk usage in human-readable format

du -sh <directory> => Shows the size of a directory

free -h => Displays memory usage

uptime => Shows system uptime

uname -a => Displays system information

history => Shows command history

Scripting and Automation

echo "Hello World" => Prints text to the terminal

bash script.sh => Executes a Bash script

chmod +x script.sh => Makes a script executable

crontab -e => Edits scheduled tasks

cronjob => Runs tasks at scheduled times

Conclusion

Understanding Linux commands is essential for managing systems efficiently. Mastering these commands helps improve productivity, and system administration, and provides a strong foundation for DevOps and cloud engineering roles.

0
Subscribe to my newsletter

Read articles from Ebube Umeobi directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Ebube Umeobi
Ebube Umeobi

Computational Social Scientist | Data Scientist | Cloud Engineer Passionate about responsible, impactful products and services.