/// article

Linux tips every geek must know

What separates average Linux users from the super-geeks? Simple: years spent learning the kinds of hacks, tricks, tips and techniques that turn long jobs into a moment’s work. If you want to get up to speed without having to put in all that leg-work, we’ve rounded up over 50 easy-to-learn Linux tips to help you work smarter and get the most from your comp...

By lordfrancs3

ific distribution, we will explain the differences. If you are completely new to Linux, we recommend reading our introductory guide, Linux Explained Simply, before proceeding. Before You Start You will need access to a Linux terminal. You can follow this guide using Ubuntu, Debian, Fedora, Rocky Linux, AlmaLinux, or another modern Linux distribution. Some commands require additional packages or administrative privileges. Whenever you encounter sudo, remember that the command may execute with elevated permissions. PinoyLinux Safety Reminder: Never execute an unfamiliar command on a production server without understanding what it does. Practice system-changing commands in a virtual machine or lab environment first. Part 1: Navigating the Linux Terminal Learning how to navigate the terminal is the foundation of working with Linux. These first five tips will help you move around the file system, inspect directories, and find information about commands. Tip 1: Find Your Current Directory With pwd Have you ever opened a terminal and wondered where you are in the Linux file system? The pwd command displays your current working directory. pwd Example output: /home/pinoylinux This tells you that your current directory is /home/pinoylinux. You will use this command when navigating unfamiliar servers, executing scripts, and managing files. PinoyLinux Tip: Before running commands that modify files, check your current directory to avoid working in the wrong location. Tip 2: List Files With Detailed Information The ls command lists files and directories. For a more informative view, use: ls -lah The options mean: Option Purpose -l Display detailed file information. -a Include hidden files. -h Display file sizes in a human-readable format. Example output: drwxr-xr-x 5 user user 4.0K Sep 25 10:00 . drwxr-xr-x 3 root root 4.0K Sep 25 09:00 .. -rw-r--r-- 1 user user 220 Sep 25 09:00 .bash_logout -rw-r--r-- 1 user user 3.7K Sep 25 09:00 .bashrc drwxr-xr-x 2 user user 4.0K Sep 25 09:30 Documents This command helps you inspect file ownership, permissions, sizes, and modification dates. It is particularly useful when troubleshooting permission problems. Tip 3: Navigate Directories Faster The cd command changes your current directory. Move into a specific directory: cd /var/log Return to your home directory: cd ~ Move one directory higher: cd .. Return to your previous directory: cd - The last example is useful when switching between two working directories. For example, you might move between your application’s configuration directory and its log directory while troubleshooting. Tip 4: Search Your Command History Linux shells such as Bash keep a history of commands you execute, subject to your shell configuration. Display your command history: history Search for previously executed SSH commands: history | grep ssh You can also press: Ctrl + R Then type part of a previous command. Bash will search backward through your command history. Press Enter to execute the selected command, or use the arrow keys to edit it first. PinoyLinux Tip: Be careful when recalling commands that contain passwords or sensitive information. Shell history may retain commands containing credentials. Tip 5: Learn Any Command With man You do not need to memorize every Linux command. Linux provides manual pages that explain command syntax, options, and behavior. For example: man ls Or: man ssh Use the arrow keys to navigate and press q to exit. If you need a quick summary, many commands also support: ls --help Not every command supports --help, so manual pages remain an important reference. Part 2: Working With Files and Directories Files are central to Linux administration. Applications, configuration files, logs, scripts, and user data all depend on the file system. These commands will help you locate, inspect, and manage them. Tip 6: Find Files by Name The find command searches directories based on conditions. Suppose you need to locate an Nginx configuration file. Run: sudo find /etc -type f -name "nginx.conf" The options mean: /etc is the starting directory. -type f searches for regular files. -name matches the filename. You can also search for log files: find /var/log -type f -name "*.log" When to use it: When you know a filename but do not know where it is stored. Tip 7: Search Inside Files With grep Sometimes you know the content you are looking for but not the filename. For example, you might need to find which Nginx configuration contains a particular domain. sudo grep -Rni "example.com" /etc/nginx/ The options mean: Option Purpose -R Search recursively. -n Display line numbers. -i Ignore letter case. This command searches the Nginx configuration directory for references to example.com. It is useful when troubleshooting virtual hosts, configuration files, and application settings. Avoid searching sensitive directories unnecessarily because results may expose credentials or other confidential information. Tip 8: Identify a File’s Actual Type A filename extension does not always tell you what a file contains. Linux provides the file command to inspect file content and identify its type. file backup.tar.gz Example output: backup.tar.gz: gzip compressed data You can also inspect an executable: file /usr/bin/bash The command can identify executable formats, scripts, images, archives, and other common file types. PinoyLinux Tip: Use file when investigating an unfamiliar file rather than assuming its contents from the filename. Tip 9: Copy Files Without Accidentally Overwriting Them The cp command copies files and directories. A basic example: cp config.conf config.conf.backup This creates a backup copy, but it can overwrite an existing destination file. For an interactive confirmation when a destination exists, use: cp -i config.conf config.conf.backup The -i option asks for confirmation before overwriting. For scripts, a different strategy may be appropriate because interactive prompts can interrupt automation. When to use it: Before modifying configuration files or testing application settings. Tip 10: Archive and Compress Directories The tar command creates and extracts archives. Suppose you want to archive a website directory: tar -czvf website-backup.tar.gz website/ The options mean: Option Purpose -c Create an archive. -z Compress using gzip. -v Display processed files. -f Specify the archive filename. Extract the archive: tar -xzvf website-backup.tar.gz Before extracting an unfamiliar archive, inspect its contents: tar -tzvf website-backup.tar.gz PinoyLinux Tip: Creating an archive is not the same as maintaining a complete backup strategy. Important backups should be stored separately and tested for successful restoration. Part 3: Monitoring System Resources When a Linux server becomes slow, stops responding, or runs out of storage, resource monitoring is usually one of the first troubleshooting steps. These commands help you inspect system health. Tip 11: Monitor CPU and Process Activity The top command displays running processes and system resource usage. top You can inspect CPU activity, memory usage, process IDs, and running applications. Press q to exit. For a more interactive experience, some distributions provide htop. On Ubuntu or Debian: sudo apt install htop Then run: htop Unlike top, htop may need to be installed separately. Tip 12: Check Available Memory Use: free -h Example output: total used free shared buff/cache available Mem: 15Gi 4.2Gi 2.1Gi 320Mi 8.7Gi 10Gi Swap: 4.0Gi 0B 4.0Gi The -h option displays values using readable units. Pay particular attention to the available column. Linux uses otherwise idle memory for caches, so a low value in the free column does not automatically mean your server is running out of memory. When to use it: When investigating slow applications, memory pressure, or unexpected server behavior. Tip 13: Check Disk Space Use: df -h This displays storage usage for mounted file systems. Example: Filesystem Size Used Avail Use% Mounted on /dev/sda2 98G 72G 21G 78% / A nearly full root file system can affect applications, databases, package updates, and logging. You can inspect a specific file system: df -h / PinoyLinux Tip: Check disk usage before large application deployments, database imports, and operating system upgrades. Tip 14: Find Large Directories The du command measures disk usage. To inspect directories under /var: sudo du -h --max-depth=1 /var To sort the results by size: sudo du -h --max-depth=1 /var | sort -h This helps identify directories consuming storage. Common locations worth investigating include: /var/log /var/cache /var/lib /home Do not delete files simply because they consume substantial disk space. Database files, container storage, and application data may be essential to running services. Tip 15: Check System Uptime The uptime command displays how long the system has been running. uptime Example output: 10:45:31 up 12 days, 4:22, 2 users, load average: 0.18, 0.25, 0.30 The output includes system uptime and load averages. Load average represents the average number of tasks that are runnable or waiting in uninterruptible sleep, typically associated with I/O. A high load average does not automatically mean the CPU is overloaded. For example, a server with 32 logical CPUs can handle a different level of runnable work from a server with two logical CPUs. Investigate load average alongside CPU utilization, memory pressure, and I/O activity. Part 4: Managing Processes and Services Applications running on Linux operate as processes. Web servers, databases, background workers, and scheduled jobs may also be managed as system services. Understanding these tools is essential for troubleshooting. Tip 16: List Running Processes Use: ps aux This displays information about active processes. To inspect a particular application: ps aux | grep nginx A more targeted alternative is: pgrep -a nginx The second command displays matching process IDs and their command lines. When to use it: When checking whether an application is running or identifying unexpected processes. Tip 17: Find Processes Consuming the Most CPU Run: ps aux --sort=-%cpu | head -n 10 This sorts the process list by reported CPU usage. To investigate memory consumption: ps aux --sort=-%mem | head -n 10 These commands are useful when a monitoring system reports a resource spike. However, ps provides a snapshot, not a continuous performance history. For ongoing monitoring, use tools such as top, Prometheus, or another monitoring solution. Tip 18: Identify Which Process Is Using a File Sometimes an application cannot access or modify a file because another process is using it. The lsof command lists open files. For example: sudo lsof /var/log/syslog You can also inspect processes associated with a network port: sudo lsof -i :443 The tool may need to be installed separately: sudo apt install lsof PinoyLinux Tip: Inspect the owning process before attempting to stop it. An unfamiliar process may belong to an important system service. Tip 19: Check the Status of a Linux Service On distributions using systemd, systemctl manages system services. Check Nginx: systemctl status nginx Check PostgreSQL: systemctl status postgresql To restart Nginx: sudo systemctl restart nginx A restart stops and starts the service, potentially interrupting active connections. For Nginx configuration changes, validate the configuration first: sudo nginx -t If the test succeeds, you can request a configuration reload: sudo systemctl reload nginx Production Caution: Always understand the impact of restarting a service before doing so. Tip 20: Investigate System Logs With journalctl On systems using systemd, journalctl provides access to journal logs. Inspect Nginx logs: sudo journalctl -u nginx Follow new log entries: sudo journalctl -u nginx -f Inspect logs from the current boot: sudo journalctl -b View only recent entries: sudo journalctl -n 50 Logs help you understand why an application failed, when a service restarted, or what happened before an incident. Part 5: Linux Networking Networking is an important part of Linux administration. Whether you are hosting a website, managing a database, or troubleshooting SSH access, these commands can help you identify connectivity problems. Tip 21: Identify Network Interfaces Use: ip link show This displays the network interfaces recognized by Linux. You might encounter names such as: lo eth0 ens18 enp1s0 The actual names depend on your hardware, virtualization platform, and operating system configuration. The ip command is part of the iproute2 networking utilities. man7.org Tip 22: Check Your IP Addresses Run: ip addr show For a shorter output: ip -br addr Example: lo UNKNOWN 127.0.0.1/8 ens18 UP 192.168.1.100/24 This helps identify which IP addresses are assigned to your interfaces. If an application is unreachable, confirm that the server is using the expected IP address. Tip 23: Inspect Network Routes Use: ip route Example output: default via 192.168.1.1 dev ens18 192.168.1.0/24 dev ens18 proto kernel scope link The default route determines where traffic is sent when no more specific route matches the destination. You can also ask Linux which route it would use for a destination: ip route get 8.8.8.8 When to use it: When troubleshooting connectivity between servers, virtual machines, and different network segments. Tip 24: Find Applications Listening on Network Ports One of the most useful Linux networking commands is: sudo ss -tulnp The options mean: Option Purpose -t Display TCP sockets. -u Display UDP sockets. -l Display listening sockets. -n Display numerical addresses and ports. -p Display process information where permitted. Suppose your Nginx service cannot start because port 443 is occupied. Run: sudo ss -tulnp '( sport = :443 )' The output may identify the process using that port. This is a useful first step when troubleshooting web server conflicts. Reference: Linux ss Manual. Tip 25: Troubleshoot DNS Resolution DNS translates domain names into IP addresses and supports other services such as email routing. The dig command helps you inspect DNS records. Check an A record: dig example.com A Check an MX record: dig example.com MX Query a specific DNS resolver: dig @1.1.1.1 example.com A Display a concise answer: dig +short example.com A PinoyLinux Tip: When a domain fails to resolve, compare responses from your configured resolver and a known public resolver. Differences can help identify caching, forwarding, or zone configuration problems. Part 6: User Accounts and Permissions Linux uses users, groups, and file permissions to control access to system resources. Understanding these concepts is important when managing shared servers and applications. Tip 26: Identify Your Current User Run: whoami Example: pinoylinux This displays the effective username associated with your current session. It is especially useful after switching accounts with su or opening a privileged shell. Tip 27: Check User and Group Membership Run: id Example: uid=1000(pinoylinux) gid=1000(pinoylinux) groups=1000(pinoylinux),27(sudo) The output shows your user ID, primary group, and supplementary groups. To inspect another account: id www-data This is useful when checking which account runs a web application and which groups it belongs to. Tip 28: Understand File Permissions Use: ls -l Example: -rw-r----- 1 pinoylinux www-data 2048 Sep 25 config.conf The permission string is divided into three categories: Owner | Group | Others rw- | r-- | --- Linux uses three basic permission types: Permission File Meaning Read (r) Read file contents. Write (w) Modify file contents. Execute (x) Execute a file where applicable. For directories, these permissions have different access implications, particularly the execute permission, which allows directory traversal. Understanding permissions helps you troubleshoot errors without granting excessive access. Tip 29: Change File Permissions The chmod command modifies file permissions. For example: chmod 600 private.conf This allows the file owner to read and write the file while removing access for the group and others. For a script: chmod 750 deploy.sh This gives the owner read, write, and execute permissions, while members of the file’s group receive read and execute permissions. Security Reminder: Avoid using chmod 777 as a general solution to permission problems. It grants read, write, and execute permissions to everyone, which can introduce unnecessary security risks. Tip 30: Change File Ownership The chown command changes file ownership. Example: sudo chown pinoylinux:pinoylinux config.conf This assigns the file to the specified user and group. To inspect the result: ls -l config.conf Ownership problems commonly occur when files are created using sudo, copied between servers, or deployed by different service accounts. Production Caution: Avoid recursively changing ownership of an application directory without checking its required permissions and service accounts. Part 7: Package Management A package manager installs, updates, and removes software. Different Linux distributions use different package management tools. The following examples use APT, which is common on Ubuntu and Debian. Tip 31: Refresh Package Information Run: sudo apt update This downloads updated package information from configured repositories. It does not install the available updates. The distinction is important because checking for updates and installing them are separate operations. Ubuntu Tip 32: Search for Available Packages Use: apt search nginx This searches configured package repositories for packages matching the term. To search for a particular utility: apt search htop Package searches help you identify software names before installation. Tip 33: List Installed Packages On Debian-based distributions, use: dpkg -l To find an installed package: dpkg -l | grep nginx You can also use: apt list --installed These commands help you confirm whether an application was installed through the operating system’s package manager. Remember that software installed through Docker, npm, source compilation, or other methods may not appear in this list. Tip 34: Find Where a Command Is Installed Use: command -v nginx Example: /usr/sbin/nginx This tells you which executable or shell-resolved command would be used in the current environment. You can also check: command -v node This is useful when troubleshooting multiple Node.js installations, Python environments, and conflicting executable paths. Tip 35: Inspect Package Information Before Installation Use: apt show nginx The output can include package version, dependencies, description, and other metadata. Before installing an unfamiliar package, review its description and dependencies. For example: apt show postgresql PinoyLinux Tip: On production servers, review software versions and dependencies before upgrading or installing packages. Package changes may affect running applications. Part 8: Working With Text and Logs Linux administrators spend considerable time reading configuration files and logs. These commands make text-based troubleshooting easier. Tip 36: Search Logs for Specific Errors The grep command searches text for matching patterns. For example: grep -i "error" application.log Search for HTTP 404 responses in an Nginx access log: sudo grep '" 404 ' /var/log/nginx/access.log You can also search recursively through a directory: sudo grep -Rni "connection refused" /var/log/ Use targeted searches when possible. Large log directories can generate substantial output. Tip 37: Monitor Logs in Real Time Use: tail -f application.log This displays the end of a file and follows new lines as they are appended. For an Nginx access log: sudo tail -f /var/log/nginx/access.log Press Ctrl + C to stop. You can also display a specified number of recent lines: tail -n 100 application.log When to use it: During application deployments, troubleshooting, and live monitoring of an individual service. Tip 38: Extract Information From Text With awk The awk command processes structured text. For example, suppose a file contains: alice 25 bob 30 charlie 28 You can display only the first field: awk '{print $1}' users.txt Output: alice bob charlie This is useful when extracting fields from reports and command output. For simple web server logs, awk can also help count requests by source IP, provided the log format is understood. Tip 39: Replace Text With sed The sed command can transform text. For example: echo "Hello Linux" | sed 's/Linux/PinoyLinux/' Output: Hello PinoyLinux To preview replacements in a configuration file: sed 's/old.example.com/new.example.com/g' config.conf This prints the transformed content without modifying the original file. PinoyLinux Tip: Preview your changes before using sed -i, which modifies files in place. Tip 40: Count Lines, Words, and Characters Use: wc application.log To count only lines: wc -l application.log This can be useful for determining the number of entries in a file. For example: grep -c "ERROR" application.log The second command counts matching lines containing ERROR. It does not necessarily count individual error occurrences if multiple matches appear on one line. Part 9: Remote Administration and SSH SSH is one of the most important tools for managing Linux servers remotely. It provides encrypted communication between your computer and a remote system. These commands are useful for system administrators, developers, and DevOps engineers. Tip 41: Connect to a Remote Linux Server The basic SSH syntax is: ssh username@server-ip Example: ssh admin@192.0.2.10 For a custom SSH port: ssh -p 2222 admin@192.0.2.10 The first time you connect, SSH may ask you to verify the server’s host key fingerprint. Verify the fingerprint through a trusted source before accepting it. This helps protect against connecting to an impersonated server. Tip 42: Generate an SSH Key Pair SSH keys allow you to authenticate using public-key cryptography. For a typical modern OpenSSH setup, generate an Ed25519 key: ssh-keygen -t ed25519 -C "admin@example.com" Follow the prompts to select a filename and passphrase. The command creates a private key and a corresponding public key. For the default filename, these are commonly: ~/.ssh/id_ed25519 ~/.ssh/id_ed25519.pub The public key can be installed on a server. The private key must remain confidential. A passphrase adds protection if someone obtains a copy of the private key. OpenSSH documents its supported key-generation options in the official manual: OpenSSH Manual Pages. OpenSSH Tip 43: Copy Files Securely With SCP The scp command copies files between computers using SSH-based transport. For example: scp backup.tar.gz admin@192.0.2.10:/home/admin/ To copy a file from the remote server: scp admin@192.0.2.10:/home/admin/report.txt . The dot represents your current local directory. Use SCP when transferring individual files or small collections between Linux systems. For large or repeated transfers, rsync may be more appropriate. Tip 44: Synchronize Directories With Rsync The rsync command synchronizes files and directories. For example: rsync -avh website/ backup/ The options mean: Option Purpose -a Archive mode. -v Display transfer information. -h Display readable file sizes. To synchronize with a remote server: rsync -avh website/ admin@192.0.2.10:/home/admin/website/ Before performing a transfer, preview the operation: rsync -avhn website/ backup/ The -n option performs a dry run. Production Caution: Rsync’s --delete option can remove destination files that are absent from the source. Avoid using it until you fully understand the synchronization direction and have reviewed a dry run. Tip 45: Execute Commands on a Remote Server SSH can execute commands without opening an interactive shell. For example: ssh admin@192.0.2.10 "uptime" Or: ssh admin@192.0.2.10 "df -h" You can inspect a remote service: ssh admin@192.0.2.10 "systemctl status nginx --no-pager" This technique is useful when administering multiple servers and gathering system information. For larger environments, configuration management tools such as Ansible can help manage repeated administrative tasks. Part 10: Linux Security and Maintenance The final five tips focus on understanding your system, checking security configurations, and inspecting operating system status. These activities should be part of regular Linux administration. Tip 46: Identify Your Linux Distribution Run: cat /etc/os-release Example output: PRETTY_NAME="Ubuntu 24.04.3 LTS" NAME="Ubuntu" VERSION_ID="24.04" ID=ubuntu The exact output depends on your installed operating system. Knowing the distribution and release is important when selecting installation instructions, repositories, and troubleshooting procedures. Do not assume that commands designed for Ubuntu will work unchanged on Fedora or Rocky Linux. Tip 47: Check Your Linux Kernel Version Use: uname -r This displays the release identifier of the currently running kernel. For additional system information: uname -a Kernel information is useful when troubleshooting drivers, hardware compatibility, and security updates. Remember that the installed kernel package and the currently running kernel may differ if the system has not been rebooted after an update. Tip 48: Inspect Firewall Rules Different Linux distributions use different firewall management systems. On Ubuntu, UFW is commonly used. Check its status: sudo ufw status verbose On systems using firewalld: sudo firewall-cmd --list-all You may also encounter nftables: sudo nft list ruleset These tools do not necessarily describe every network security control affecting your server. Cloud firewalls, network access control lists, and upstream security devices may enforce additional restrictions. Production Caution: Never modify firewall rules on a remote server without confirming that your SSH management connection will remain accessible. Tip 49: Check Time Synchronization Accurate system time is important for logs, authentication, certificates, monitoring, and distributed applications. On systems using systemd, run: timedatectl Example output may include: System clock synchronized: yes NTP service: active The displayed fields depend on the system configuration. You can also inspect the configured time synchronization service. For systems using systemd-timesyncd: systemctl status systemd-timesyncd Other systems may use Chrony or another NTP implementation. PinoyLinux Tip: When comparing logs across multiple servers, confirm that their clocks are synchronized and account for differences in displayed time zones. Tip 50: Investigate What Happened During System Boot The final tip is useful when a server restarts unexpectedly or fails to start an application after rebooting. Inspect logs from the current boot: sudo journalctl -b Display warnings and more severe messages: sudo journalctl -b -p warning List recorded boot sessions: sudo journalctl --list-boots Inspect the previous boot, if its logs are available: sudo journalctl -b -1 Previous boot logs may be unavailable if journal persistence is disabled or older records have been removed. When to use it: When investigating unexpected restarts, failed services, boot problems, and system errors. Bonus: Five Habits That Will Make You Better at Linux Knowing commands is useful, but developing good administration habits matters just as much. Here are five practices worth adopting. 1. Read Before Executing Never copy and execute a command simply because you found it in a tutorial. Understand what it does, which files it affects, and whether it requires elevated privileges. 2. Maintain Backups Before changing important configurations, preserve the original files. For example: sudo cp -a /etc/nginx/nginx.conf /etc/nginx/nginx.conf.backup For production systems, maintain separate, tested backups instead of relying only on copies stored on the same server. 3. Learn to Read Logs When an application fails, logs often provide useful information about the cause. Before repeatedly restarting a service, inspect its status and relevant logs. For example: systemctl status nginx sudo journalctl -u nginx -n 100 Understanding error messages will help you develop troubleshooting skills. 4. Practice in a Lab Environment Create a Linux virtual machine and experiment with commands. Install a web server, configure a database, create user accounts, and practice managing services. You can also intentionally create simple problems in your lab and learn how to resolve them. Never introduce these experiments into a production environment without authorization. 5. Document Your Work Keep a record of important configurations, commands, and troubleshooting procedures. For example, document how you installed Nginx, configured HTTPS, or recovered a failed application. These notes can become useful references for future incidents and recurring maintenance tasks. They can also form the foundation of tutorials that you share with the Linux community. Frequently Asked Questions Do I need to memorize all 50 Linux commands? No. Focus on understanding what the commands do and where to find their documentation. You will naturally remember the commands you use frequently. Are these commands compatible with every Linux distribution? Most basic commands work across modern Linux distributions. However, package managers, firewall tools, service management systems, and installed utilities can differ. Always check the documentation for your distribution. Is it safe to execute these commands on a production server? Many of the inspection commands are read-only and suitable for routine troubleshooting. However, commands that modify permissions, ownership, files, services, or packages can affect running applications. Review their effects before executing them on a production system. What should I learn after these commands? A useful next step is to study Bash scripting, Linux networking, systemd, SSH security, file permissions, and server administration. If your goal is DevOps or cloud engineering, you can continue with Git, Docker, infrastructure automation, monitoring, and cloud platforms. Continue Learning With PinoyLinux Linux is a practical skill. The more you use it, the more familiar you become with its commands, utilities, and system behavior. Start with the commands that are relevant to your daily tasks. Practice them, understand their output, and gradually introduce more advanced techniques. If you are a student, a developer, a system administrator, or someone interested in open-source technology, you can continue your learning journey with PinoyLinux. Explore our tutorials, technical guides, and community resources at PinoyLinux.org. Have a Linux tip that helped you solve a difficult problem? Share it with the PinoyLinux community. Your experience might help another Filipino IT professional or student solve the same problem.