100 Useful Basic Linux Commands — A Complete Guide for Beginners

Linux is one of the most powerful operating systems, widely used for servers, development, and even everyday computing. At the heart of Linux lies its command line interface (CLI), which gives you direct control over the system.

Whether you are a beginner or someone brushing up your skills, this guide covers 100 useful basic Linux commands that will make navigating, managing, and troubleshooting your system easier.

Navigating the File System:
1ls: List files and directories in the current location.
2cd: Change directory.
3pwd: Print the working directory.
File Manipulation:
4cat: Display the contents of a file.
5less: View file content page by page.
6more: View file content page by page.
7head: Display the first few lines of a file.
Example: head -n 5 filename
8tail: Display the last few lines of a file.
Example: tail -n 10 filename
9tail -f: Continuously display the last lines of a file (useful for monitoring log files).
Example: tail -f /var/log/syslog
10diff: Compare the content of two files and display the differences.
Example: diff file1 file2
Viewing and Editing Files:
11mkdir: Create a new directory.
12touch: Create an empty file.
13nano or vim: Text editors to create or modify files.
14cp: Copy files or directories.
15mv: Move or rename files or directories.
16rm: Remove files or directories.
17rmdir: Remove empty directories.
18wc: Count lines, words, and characters in a file.
19ln: Create hard or symbolic (soft) links to files.
Example: ln -s target_file link_name
20stat: Display file or file system status information.
Example: stat filename
Searching and Filtering:
21grep: Search for patterns in files or output.
22find: Search for files and directories.
Example: find /path/to/search -name "filename"
23locate: Find files by name quickly using a pre-built database.
Example: locate filename (search for a file by its name)
Text Manipulation:
24sed: Stream editor for text manipulation (search and replace, etc.).
Example: sed 's/old/new/g' filename (replace all occurrences of 'old' with 'new' in the file)
Process Management:
25ps: Display information about running processes.
Example: ps -ef
26pstree: Display a tree of processes, showing their parent-child relationships.
Example: pstree
27kill: Terminate processes.
28pkill: Send signals to terminate processes based on their names or attributes.
Example: pkill -SIGKILL process_name (force-kill processes by name)
29nohup: Run a command immune to hangups, even if the user logs out (disconnects from the session).
Example: nohup long_running_command & (run a command in the background, immune to logout)
Resource Monitoring:
30date: Display the current date and time.
31Cal : Display the calender
31uptime: Display the system's uptime and load average.
Example: uptime
32hostname: Show the system's hostname.
Example: hostname
34history: Display the command history for the current shell session.
Example: history
35top: Monitor system processes and resource usage.
36df -Th: Show disk space usage.
37du -sh: Display disk usage of files and directories in a human-readable format.
Example: du -h /path/to/directory
38free -Th: Display system memory usage in a human-readable format.
Example: free -h
39vmstat: Report virtual memory statistics (CPU, memory, and I/O).
- Example: vmstat 1 (output statistics every 1 second)
System Monitoring:
40sar: Collect and report system activity information (requires installation).
41iostat: Report CPU and I/O statistics (requires installation).
Example: iostat
42tee: Read from standard input and write to standard output and files simultaneously.
Example: command | tee output_file.txt (save command output to a file and display it in the terminal)
Memory Usage:
43pmap: Display memory map of a process.
Example: pmap PID (show memory usage of a process with the specified PID)
User Management:
44whoami: Display the current user's username.
45id: Show user and group information for the current user.
46Chage -l root : Display user details
47su: Switch user or become a superuser (root) with a different user's credentials.
Example: su username (switch to the specified user)
sudo: Execute a command with administrative privileges.
48useradd: Create a new user account.
Example: useradd new_username
49passwd: Change the password for a user account.
Example: passwd username
50usermod: Modify user account settings.
Example: usermod -aG group_name username
51userdel: Delete a user account.
Example: userdel username
52groupadd: Create a new user group.
Example: groupadd groupname
52groupadel: delete a new user group.
Example: groupdel groupname
53groups: Display the groups a user belongs to.
Example: groups username
Permissions:
54chmod: Change file permissions.
Example: chmod u+x file (add execute permission for the owner) or chmod 755 file (give read, write, and execute permissions to the owner, and read and execute permissions to the group and others)
Example: chown user:group file (change the owner and group of a file)
55chown: Change file ownership.
umask: Set the default permissions for newly created files and directories.
Example: umask 022 (set default permissions to 644 for files and 755 for directories)
56chgrp: Change the group ownership of a file or directory.
Example: sudo chgrp new_groupname file (change the group ownership of a file)
Network Management :
57ifconfig (or ip addr show): Display network interface information.
58ip: Show or manipulate routing, devices, and policy routing.
Example: ip addr (display network interface addresses) or ip route (display routing table)
Example: ifconfig or ip addr show
59ping: Send ICMP echo requests to a host to check network connectivity.
Example: ping google.com
60nslookup (or dig): Query DNS servers to retrieve domain name or IP address information.
Example: nslookup example.com or dig example.com
61netstat: Show network statistics, including open ports and active connections.
Example: netstat -tuln | grep 3300
62traceroute: Trace the route packets take to reach a destination.
Example: traceroute google.com
Network Diagnostics:
63nmap: Network exploration tool and security scanner.
Example: nmap -p 1-1000 target_ip (scan the first 1000 ports of a target IP address)
64ip route: Display or manipulate the routing table.
Example: ip route show (display the routing table)
65tcpdump: Capture and display network traffic.
66telnet: Connect to a remote host using the Telnet protocol (requires installation).
Package Management:
67yum list: List installed and available packages (for RPM-based distributions).
rpm -qa | grep tomcat
68apt (or apt-get): Package manager for Debian-based distributions (e.g., Ubuntu).
Example: sudo apt update (update package lists) or sudo apt install package_name (install a package)
69yum: Package manager for Red Hat-based distributions (e.g., CentOS).
Example: sudo yum update (update packages) or sudo yum install package_name (install a package)
70which: Display the location of a command.
71whatis: Display the use of the command
File Compression and Archiving:
72tar: Create, extract, or manipulate tar archives.
tar -zcvf: Create a compressed tar archive (tarball) using gzip compression.
Example: tar -zcvf archive.tar.gz files
tar -jcvf: Create a compressed tar archive using bzip2 compression.
Example: tar -jcvf archive.tar.bz2 files
73gzip (or gunzip): Compress or decompress files using gzip compression.
Example: gzip filename or gunzip filename.gz
74zip (or unzip): Create, list, and extract ZIP archives.
Example: zip archive.zip files or unzip archive.zip
Hardware
75uname -r: Display the kernel release.
- Example: uname -r
76dmesg: Display the kernel ring buffer to view system messages, including boot messages.
Example: dmesg | tail (display the last few kernel messages)
77lshw: List hardware information (requires installation).
Example: sudo lshw (display detailed hardware information)
78lsmod: List loaded kernel modules.
Example: lsmod (display the list of loaded kernel modules)
Remote Command Execution: Jobs
79cron: A time-based job scheduler for running commands at specified intervals.
crontab: Schedule commands to run at specified intervals using cron.
80at: Schedule a one-time command to run at a specific time.
Example: echo "command_to_run" | at HH:MM
Disk Usage and Space Monitoring:
81watch: Execute a command repeatedly and display its output in real-time.
Example: watch df -h (monitor disk space usage in real-time)
File system Management
82mount: Mount a file system to a specific directory.
Example: sudo mount /dev/sdX1 /mnt (mount a partition to the /mnt directory)
83umount: Unmount a mounted file system.
Example: sudo umount /mnt (unmount the file system mounted at /mnt)
Files download
84wget: Download files from the web using HTTP, HTTPS, or FTP protocols.
Example: wget https://example.com/file
Example: sudo command (run the command with root privileges)
FTP
85ftp: Connect to a remote host using the File Transfer Protocol.
Example: ftp ftp.example.com (connect to the FTP server)
86sftp: Securely transfer files to and from a remote host over SSH.
Example: sftp user@remote_host (connect to the remote host using SFTP)
File Transfer:
87scp: Securely copy files between local and remote hosts over SSH.
Example: scp local_file remote_user@remote_host:/remote/path
Firewall Configuration:
88iptables -L
System Logs:
89journalctl: Query the systemd journal for system log messages.
90screen: Terminal multiplexer that allows running multiple sessions in a single terminal (requires installation).
Managing Services:
91systemctl: Control and manage systemd services.
92service: Control and manage system services (older systems using SysV init).
Example: sudo service service_name start (start a service)
Managing Environment Variables:
93set: Set environment variables.
94unset: Unset environment variables.
Disk Management:
95fdisk: Create, view, or manipulate disk partitions (requires superuser privileges).
96lsblk: List information about available block devices (disks and partitions).
Example: lsblk
File Permissions and Ownership:
97sort: Sort lines of text files.
Example: sort filename (sort lines in ascending order)
System Maintenance:
98shutdown: Schedule a system shutdown or reboot.
- Example: sudo shutdown -r now (reboot immediately) or sudo shutdown -h +5 (shutdown in 5 minutes)
99reboot: Reboot the system.
Example: sudo reboot

You can drop the mail to shekhar.ankam5050@gmail.com if any changes required on the page..
Thanks for visiting the page.

Comments

Popular posts from this blog

Awk command with simple examples

Learn Linux in Telugu | Linux complete Free Course in Telugu by 7Hills

rsync Command Examples | rsync Command In Telugu

How to reduce LVM partition size in RHEL and CentOS