Commandline Basics

Knowing the Linux command line is essential for leveraging the full potential of Linux systems, particularly in technical fields such as cybersecurity, software development, and system administration. The command line offers unmatched control and flexibility, allowing users to perform tasks more efficiently than through graphical interfaces. With the command line, users can quickly manage files, configure systems, automate repetitive tasks using shell scripts, and troubleshoot issues. Its power and precision make it indispensable for professionals managing servers, networks, and cloud environments where remote and headless systems are common.

The benefits of mastering the Linux command line extend beyond efficiency. It enhances problem-solving skills by providing access to powerful tools like grep, awk, sed, and find for data processing and analysis. Additionally, understanding command-line basics is critical for security professionals who need to investigate logs, monitor system activity, and respond to threats in realtime. Familiarity with the command line also fosters a deeper understanding of how Linux operates, enabling users to optimise system performance, enhance security, and customise environments to fit specific needs. In a world increasingly reliant on open-source technologies, command-line proficiency is a vital skill that opens doors to innovation and career advancement.

The following is a set of commands that are useful to know as a security professional, as they can be used to triage and help determine the state of a host or environment. The commands are designed to quickly grab the relevant information that will allow the investigator to determine whether the activity warrants deeper analysis or escalation.

Note: Depending on the distro of the system being investigated, in certain situations, the commands present may not return the desired information; at that point, you will have to customise the queries to the distro being investigated.

Print Working Directory (PWD)
Command: pwd
Description: Prints the current working directory
Example: pwd #displays the full path of the current directory
echo "You are in $(pwd)" #Combining with Other Commands
List (LS)
Command: ls
Description: Lists directory contents
Example: 
    ls -l #lists files in long format, showing permissions, owner, size, and modification date
    ls -a #lists files, including hidden files (those starting with a dot)
    ls -la #list directory contents in a long format, including hidden files
    ls -l /etc/shadow
Change Directory (CD)
Command: cd
Description: Changes the current directory.
Example: 
cd /home/user #changes the directory to /home/user
cd /home/user  #Changing to a Specific Directory
cd .. #Moving Up One Directory Level
cd ~ #Moving to the Home Directory
cd - #Changing to the Previous Directory
cd /var/log #Using Absolute and Relative Paths

Last updated