Hello, you are using an old browser that's unsafe and no longer supported. Please consider updating your browser to a newer version, or downloading a modern browser.
Published by Mike McNelis on October 14, 2025
The terminal still intimidates people, and I get it. That black screen with white text doesn’t give you much feedback, and one wrong command can mess things up. I’ve seen experienced IT professionals who can troubleshoot network issues in their sleep get nervous when they need to navigate Linux from the command line.
Here’s what I tell people: you don’t need to become a Linux expert overnight. You just need to know the commands that matter for security. The same dozen or so commands will handle most of what you actually need to do. If you’re working in IT, you’re going to run into Linux. It’s everywhere. Cloud servers, containers, networking equipment, IoT devices. And whether you’re managing your first server or supporting enterprise infrastructure, understanding basic Linux security commands isn’t optional anymore. It’s part of the job.
Here’s something nobody tells beginners: you don’t need to memorize hundreds of Linux commands. Even experienced administrators keep a cheat sheet handy. What you do need is a solid understanding of the commands that keep your system secure, because whether you’re managing a home server, working toward your first IT job, or maintaining enterprise infrastructure, these commands are your first line of defense. Linux powers everything from Android phones to the world’s largest supercomputers. It runs the majority of web servers, cloud infrastructure, and embedded systems. According to the Linux Foundation, Linux dominates over 90% of public cloud workloads. That means if you’re working in IT, you’re going to encounter Linux. And when you do, knowing basic security commands separates the people who can actually solve problems from the ones who panic and escalate everything.
Think of Linux security commands like knowing how to check your car’s oil, tire pressure, and brake fluid. You might not be a mechanic, but these basic checks keep you from getting stranded. Same principle applies here.
That terminal window looks complicated, but underneath all that, you’re just typing instructions that the computer follows. No different than using any other interface, except instead of clicking buttons, you’re typing commands. The dollar sign or hash at the start of your terminal line is the prompt. Dollar sign means you’re a regular user. Hash means you’re root, the superuser with complete system access. If you see the hash and didn’t intentionally become root, stop and figure out why. Root is like having the master key to every door in a building. Powerful, yes. Something you should use constantly? No. You run most commands as a regular user and only elevate to root when necessary using sudo.
Most Linux commands follow a simple pattern: command, options, arguments. For example, ls lists files, ls -la lists all files with details, and ls -la /home lists all files with details in the home directory. Options usually start with a dash. Every command comes with a manual. Type man followed by any command name to see its documentation. They’re often dry, but they’re comprehensive and always available, even without internet.
The sudo command lets you run commands with administrative privileges without logging in as root. This is important for security because it means you only elevate your privileges when necessary, and everything you do with sudo gets logged. Think of it as checking out the master key from security, using it, then returning it immediately. Basic usage: sudo [command]. For example, sudo apt update runs the package update command with root privileges. You’ll be prompted for your password. If you’re in the sudoers file, the command executes. If not, you get denied and the attempt gets logged. If you need to run multiple commands as root, use sudo su to become root temporarily rather than typing sudo before every command. Just remember to type exit when you’re done. I’ve seen people forget they’re running as root and accidentally break their entire system.
The whoami command returns your current username. Simple, but useful when you’re switching between users or working on multiple systems. The id command gives you more detail: your user ID, group ID, and all groups you belong to. This matters because Linux permissions are based on user IDs and groups. When you’re troubleshooting why you can’t access a file, id tells you exactly what permissions you have. The passwd command changes passwords. Run it without arguments to change your own password. Run sudo passwd username to change someone else’s password if you have the privileges. The system will prompt you for the new password twice to confirm. Here’s what catches beginners: Linux doesn’t show any characters when you type a password. No asterisks, no dots, nothing. You’re typing, the system is recording it, but you get zero visual feedback. That’s just how it works. Type your password, hit enter, trust the process.
Linux file permissions are straightforward. Every file and directory has three sets of permissions: one for the owner, one for the group, and one for everyone else. Each set can include read, write, and execute permissions. Understanding these is fundamental to Linux security. The Center for Internet Security identifies proper file permissions as one of the critical security controls for any Linux system. Before you can change permissions, you need to see what they are. The command ls -l lists files in long format, showing all the permission details. You’ll see something like: -rw-r–r– 1 mike users 2048 Jan 15 10:30 important_file.txt
That first group of letters shows permissions. The first character indicates file type. A dash means regular file, d means directory. The next nine characters are permissions in groups of three: owner, group, and others. Each group shows read, write, and execute permissions. A dash means that permission is not granted. Read permission lets you view file content. Write permission lets you modify or delete the file. Execute permission lets you run the file as a program. For directories, read lets you list contents, write lets you create or delete files inside, and execute lets you access the directory.
| Permission | Symbol | Numeric Value | What It Means |
|---|---|---|---|
| Read | r | 4 | Can view the file content |
| Write | w | 2 | Can modify or delete the file |
| Execute | x | 1 | Can run the file as a program |
| No Permission | – | 0 | Cannot access in this way |
Table 1: Linux Permission Values
The chmod command modifies file permissions. You can use symbolic notation with letters or numeric notation with numbers. Both work, and most admins use whichever one they remember in the moment. Symbolic method: chmod u+x filename adds execute permission for the user. The u means user, the plus sign means add, and x means execute. You can also use g for group, o for others, and a for all. Use minus to remove permissions. Numeric method: chmod 755 filename sets permissions using numbers. Add up the values for each permission type, and you get a number for each group. So 755 means owner gets read, write, and execute. Group and others get read and execute. Common permissions are 644 for regular files and 755 for executables and directories. chmod 777 gives full permissions to everyone and is almost always wrong. Yes, it will fix your permission problem. It will also give every user and every process complete access to that file. Use 777 on a production system and you’re asking for trouble.
The chown command changes who owns a file or directory. You’ll need sudo for this because regular users can’t just give away ownership. Basic syntax: sudo chown username filename. You can change both owner and group at once: sudo chown username:groupname filename. The colon separates the user from the group. This is useful when setting up web servers or shared directories where specific users and groups need specific access. The recursive flag changes ownership of a directory and everything inside: sudo chown -R username:groupname /path/to/directory. Be careful with this. Recursively changing ownership of the wrong directory creates a mess.
Understanding what’s running on your system is critical for security. Malware runs quietly in the background. These commands help you see what’s actually happening right now. The ps command shows running processes. By itself, it only shows processes in your current terminal session. But ps aux shows every process on the system with detailed information about who’s running it and resource usage. When you run ps aux, you’ll see columns for user, process ID, CPU usage, memory usage, and the command. This is your first stop when something seems wrong. High CPU usage? Check ps aux. Mystery process eating memory? Check ps aux.
The top command gives you a live view of system processes. You’ll see processes sorted by CPU usage, updating every few seconds. Press q to quit. The htop command is more user friendly. It’s not always installed by default, but worth adding. Htop gives you the same information with a better interface, color coding, and easier process management. The kill command sends signals to processes. The default signal politely asks the process to shut down. Most programs will clean up and exit when they receive this signal. If a process refuses to stop, use kill -9 followed by the process ID. This immediately terminates the process. The process doesn’t get to save its work or clean up. Use this when necessary, but try the polite approach first. The killall command stops all processes with a specific name. For example, killall firefox closes all Firefox processes. This is convenient but potentially dangerous. Make sure you’re killing what you think you’re killing.
Your network connections carry both legitimate traffic and potential attacks. These commands help you see what’s connecting to your system and what ports are open. The netstat command shows network connections, routing tables, and statistics. The most useful variation is netstat -tulpn. The flags show TCP connections, UDP connections, listening ports, the program using each port, and numerical addresses. When you run this, you’ll see what ports your system is listening on and what’s actively connected. If you see a port open that shouldn’t be, or a connection to an unknown IP address, investigate. The ss command is replacing netstat on newer systems because it’s faster and more detailed. The syntax is similar: ss -tulpn gives you the same information. Some distributions are deprecating netstat, so learn ss even if you’re comfortable with netstat. On systems with thousands of connections, netstat can be slow. The ss command uses more efficient methods and returns results almost instantly.
Iptables is Linux’s built in firewall. It’s powerful and complex. What you need to know: iptables controls what network traffic is allowed in and out by matching packets against rules. To view current rules: sudo iptables -L -v. If you see many ACCEPT rules and no DROP or REJECT rules, your firewall is essentially wide open. For beginners, use ufw instead. Ufw makes firewall management straightforward. Enable it with sudo ufw enable. Allow specific services with sudo ufw allow ssh or sudo ufw allow 80/tcp. Check status with sudo ufw status. You’ve got a working firewall without complexity. I worked with a client who disabled their firewall temporarily to troubleshoot. They forgot to turn it back on. Three days later, their server was compromised. Firewall stays on. If something doesn’t work with the firewall enabled, fix the rules. Don’t disable the firewall.
Logs tell you what happened, when it happened, and often who did it. Learning to read logs is critical for troubleshooting and security. According to NIST’s Guide to Computer Security Log Management, effective log monitoring and analysis is one of the most important defensive measures for detecting security incidents early. Log files live in /var/log/ on most systems. The tail command shows the last few lines of a file. Running tail -f /var/log/syslog follows the log in real time, showing new entries as they’re written. Useful when testing something and wanting immediate feedback. The less command lets you scroll through a file. Use less to read logs at your own pace. Press slash to search, n to go to the next match, and q to quit.
The grep command searches for patterns in files. Basic usage: grep “search term” filename. For example, grep “failed” /var/log/auth.log shows all lines containing “failed,” which usually means someone tried and failed to log in. Make grep case insensitive with -i, show line numbers with -n, and search directories with -r. For finding security issues: sudo grep -i “failed\|error\|unauthorized” /var/log/auth.log. This searches for any of those terms and highlights potential problems. You can pipe commands together. For example, ps aux | grep apache shows only processes with apache in their name. This filters large outputs down to what matters.
The last command shows successful logins. Run it to see who logged in, from where, when, and for how long. Essential for security audits. If you see logins you don’t recognize, from strange locations, or at odd times, you may have found unauthorized access. The lastb command shows failed login attempts and requires sudo. A few failed attempts might be someone forgetting their password. Hundreds from an unknown IP address? That’s an attack. Time to block that IP. These login history commands are your security time machine. They show you exactly who’s been accessing your system and who’s been trying to get in. Check them regularly, especially on any system exposed to the internet.
You now have the essential Linux security commands. But knowing commands is just the start. Real skill comes from understanding when to use them, what to look for, and how to interpret results. That takes practice. Set up a virtual machine or cloud instance to practice. Break things on purpose. See what happens when you chmod the wrong directory. Watch what logs appear when you SSH with the wrong password. The more you experiment safely, the better you’ll be when it matters.
If you’re building an IT career, understanding Linux is essential. Certifications like CompTIA A+ and CompTIA Linux+ can validate your knowledge. But more than any certification, hands on experience with these commands makes you valuable to employers. Start checking your systems regularly. Look at running processes. Review your firewall rules. Check login attempts. Search your logs for errors. Make it a habit. The people who succeed with Linux aren’t the ones who memorize man pages. They’re the ones who get comfortable using these tools every day until it becomes second nature.
Linux security doesn’t have to be intimidating. Start with these essential commands, practice regularly, and the terminal will become familiar territory instead of something to avoid. The command line is just a tool. And now you know how to use it to keep your systems secure.
Back to All Posts