Linux Commands from A to Z | TechNomadiX
Post

Linux Commands from A to Z

Enhance your efficiency by mastering these essential Linux commands.

Linux Command Line


Linux is a powerful and versatile operating system, renowned for its command-line utilities that offer unparalleled control over the system. Whether you’re a system administrator, developer, or an enthusiast, understanding these commands can significantly streamline your workflow. In this comprehensive guide, we cover a wide array of Linux commands, organized alphabetically for easy reference.

Table of Contents


A

alias

The alias command allows you to create shortcuts for other commands, reducing repetitive typing and simplifying complex command lines.

Example:

1
alias ll='ls -la'

This command creates an alias ll for ls -la, allowing quicker access to detailed directory listings.

at

The at command schedules commands or scripts to run once at a specified time, ideal for tasks that don’t need regular scheduling.

Usage:

1
2
at 2pm
at> /path/to/script.sh

This schedules script.sh to run at 2 PM.

awk

awk is a powerful text-processing tool used for pattern scanning and processing. It can manipulate data files and generate reports.

Example:

1
awk '/search_pattern/ { action }' file.txt

This command searches for a pattern and performs an action when the pattern is found.

B

basename

The basename command extracts the file name from a given path, which is particularly useful in scripting.

Example:

1
basename /path/to/file.txt

Output:

1
file.txt

This helps in focusing on essential data, reducing unnecessary processing.

C

cal

The cal command displays a simple calendar in the terminal.

Usage:

1
cal

This shows the current month’s calendar, aiding in quick date references without switching contexts.

cat

cat concatenates and displays file content. It’s essential for viewing files quickly.

Example:

1
cat file.txt

This displays the content of file.txt.

cd

The cd (change directory) command navigates between directories.

Usage:

1
cd /path/to/directory

Efficient navigation reduces time waste, aligning with Lean principles.

chgrp

chgrp changes the group ownership of files or directories.

Example:

1
chgrp group_name file.txt

Proper permission management prevents errors and rework.

chmod

The chmod command modifies file permissions, crucial for security.

Example:

1
chmod 755 script.sh

Sets read, write, execute permissions appropriately.

chown

chown changes the ownership of files and directories.

Usage:

1
chown user:group file.txt

cp

The cp command copies files and directories.

Example:

1
cp source.txt destination.txt

cron

cron schedules recurring tasks, automating routine operations.

Usage:

Edit the crontab with:

1
crontab -e

Schedule tasks using cron expressions.

curl

curl transfers data from or to a server, supporting various protocols.

Example:

1
curl -O http://example.com/file.txt

Downloads file.txt from the server.

cut

The cut command removes sections from each line of files, useful for processing data.

Example:

1
cut -d',' -f1 file.csv

Extracts the first field from a CSV file.

D

date

Displays or sets the system date and time.

Usage:

1
date

Shows the current date and time.

dd

dd copies and converts files at a low level, often used for creating disk images.

Example:

1
dd if=/dev/sda of=/backup/image.img

Creates an image of the disk /dev/sda.

df

Displays disk space usage.

Usage:

1
df -h

Shows disk usage in a human-readable format.

diff

Compares files line by line.

Example:

1
diff file1.txt file2.txt

Highlights differences between two files.

dig

dig queries DNS name servers, useful for network troubleshooting.

Usage:

1
dig example.com

Retrieves DNS information for example.com.

dirname

Extracts the directory path from a file path.

Example:

1
dirname /path/to/file.txt

Output:

1
/path/to

du

Estimates file and directory space usage.

Usage:

1
du -sh /path/to/directory

Displays the size of a directory.

E

echo

Outputs the strings it is passed as arguments.

Example:

1
echo "Hello, World!"

Displays Hello, World!.

emacs

An extensible, customizable text editor.

Usage:

1
emacs file.txt

Opens file.txt in Emacs editor.

expand

Converts tabs to spaces in files.

Example:

1
expand -t 4 file.txt

Converts tabs to four spaces.

F

file

Determines the file type.

Usage:

1
file file.txt

Displays the type of file.txt.

find

Searches for files in a directory hierarchy.

Example:

1
find /path -name "filename"

Locates files named filename under /path.

findmnt

Displays a list of mounted file systems.

Usage:

1
findmnt

fmt and fold

Formats text to fit within a specified width.

Usage:

1
fmt -w 80 file.txt

Wraps text at 80 characters.

free

Displays memory usage.

Usage:

1
free -h

Shows memory usage in human-readable format.

fsck

Checks and repairs a Linux file system.

Usage:

1
sudo fsck /dev/sda1

G

grep

Searches for patterns in files.

Example:

1
grep "search_term" file.txt

Finds lines containing search_term.

groupadd

Creates a new user group.

Usage:

1
sudo groupadd group_name

groupdel

Deletes a user group.

Usage:

1
sudo groupdel group_name

groupmod

Modifies a user group.

Usage:

1
sudo groupmod -n new_name old_name

groups

Displays group memberships.

Usage:

1
groups username

H

Displays the first lines of a file.

Example:

1
head -n 5 file.txt

Shows the first five lines.

history

Shows command history.

Usage:

1
history

I

id

Displays user and group information.

Usage:

1
id username

J

jobs

Lists active jobs in the current shell session.

Usage:

1
jobs

L

less

Allows backward and forward navigation through a file.

Usage:

1
less file.txt

ln

Creates links between files.

Example:

1
ln -s /path/to/file.txt linkname

Creates a symbolic link.

locate

Finds files by name using a pre-built database.

Usage:

1
locate filename

ls

Lists directory contents.

Usage:

1
ls -la

Shows detailed list including hidden files.

lsof

Lists open files and the processes using them.

Usage:

1
lsof -i

Displays open network connections.

M

mkdir

Creates directories.

Usage:

1
mkdir new_directory

mkfs

Builds a Linux file system on a device.

Example:

1
sudo mkfs.ext4 /dev/sdb1

Formats the partition as ext4.

more

Displays files one screen at a time.

Usage:

1
more file.txt

mv

Moves or renames files and directories.

Usage:

1
mv oldname.txt newname.txt

N

nc (netcat)

A versatile networking utility for reading from and writing to network connections.

Example:

1
nc -l 1234

Listens on port 1234.

nohup

Runs a command immune to hangups.

Usage:

1
nohup script.sh &

nslookup

Queries Internet name servers.

Usage:

1
nslookup example.com

P

passwd

Changes user passwords.

Usage:

1
passwd username

paste

Merges lines of files.

Example:

1
paste file1.txt file2.txt

ping

Sends ICMP ECHO_REQUEST to network hosts.

Usage:

1
ping example.com

printf

Formats and prints data.

Example:

1
printf "Name: %s\n" "Linux"

ps

Reports a snapshot of current processes.

Usage:

1
ps aux

R

read

Reads a line from standard input.

Usage:

1
read variable

reboot

Reboots the system.

Usage:

1
sudo reboot

rename

Renames multiple files.

Example:

1
rename 's/old/new/' *.txt

rm

Removes files or directories.

Usage:

1
rm file.txt

rsync

Synchronizes files and directories.

Example:

1
rsync -av source/ destination/

S

scp

Securely copies files between hosts.

Usage:

1
scp file.txt user@remote_host:/path

screen

Terminal multiplexer for managing multiple sessions.

Usage:

1
screen

sed

Stream editor for filtering and transforming text.

Example:

1
sed 's/old/new/g' file.txt

seq

Generates sequences of numbers.

Usage:

1
seq 1 10

sleep

Delays for a specified amount of time.

Usage:

1
sleep 5

source

Executes commands from a file in the current shell.

Usage:

1
source script.sh

stat

Displays file or file system status.

Usage:

1
stat file.txt

T

tail

Displays the last part of files.

Usage:

1
tail -n 10 file.txt

tar

Archives files.

Example:

1
tar -cvf archive.tar /path/to/files

tee

Reads from standard input and writes to standard output and files.

Usage:

1
command | tee output.txt

time

Measures program execution time.

Usage:

1
time script.sh

timeout

Runs a command with a time limit.

Usage:

1
timeout 5s command

top

Displays real-time system processes.

Usage:

1
top

touch

Updates file timestamps or creates empty files.

Usage:

1
touch newfile.txt

tr

Translates or deletes characters.

Example:

1
tr '[:lower:]' '[:upper:]' < file.txt

type

Indicates how a command name is interpreted.

Usage:

1
type ls

U

ulimit

Controls user resource limits.

Usage:

1
ulimit -n 1024

uname

Prints system information.

Usage:

1
uname -a

uniq

Filters out repeated lines in a file.

Usage:

1
uniq file.txt

useradd

Creates a new user account.

Usage:

1
sudo useradd username

userdel

Deletes a user account.

Usage:

1
sudo userdel username

usermod

Modifies a user account.

Usage:

1
sudo usermod -aG groupname username

V

vim

A highly configurable text editor.

Usage:

1
vim file.txt

W

watch

Executes a program periodically.

Usage:

1
watch -n 5 command

wc

Counts lines, words, and bytes.

Usage:

1
wc file.txt

which

Shows the full path of shell commands.

Usage:

1
which ls

who

Shows who is logged on.

Usage:

1
who

By familiarizing yourself with these commands, you can significantly enhance your productivity and reduce inefficiencies in your workflow, embodying an approach to continuous improvement.

Mastering Linux commands is essential for efficient system management and development. This comprehensive guide provides a foundation for understanding and utilizing these tools effectively.

This post is licensed under CC BY 4.0 by the author.