Unix commands for beginner IT professional.

Introduction:

Unix commands form the backbone of system administration and cybersecurity tasks, offering powerful tools for managing, monitoring, and securing Unix-based systems. In this comprehensive guide, we'll explore some of the most essential Unix commands that every sysadmin and cybersecurity professional should know. We'll dive into their usage, options, and best practices, covering a wide range of tasks from file management to network security.


  1. ls​: This command is used to list the files and directories in the current directory.
  2. cd​: This command is used to change the current directory. For example, to move to a directory named "documents", you would type cd documents.
  3. pwd​: This command prints the current working directory, showing you the full path of the directory you are currently in.
  4. mkdir​: This command is used to create a new directory. For example, to create a directory named "projects", you would type mkdir projects.
  5. rmdir​: This command is used to remove an empty directory. Be cautious when using this command as it will not work if the directory is not empty.
  6. cp​: This command is used to copy files or directories. For example, to copy a file named "file1.txt" to a directory named "backup", you would type cp file1.txt backup.
  7. mv​: This command is used to move or rename files or directories. For example, to move a file named "file1.txt" to a directory named "documents", you would type mv file1.txt documents.
  8. rm​: This command is used to remove files or directories. Be careful when using this command as it will permanently delete the files or directories.
  9. cat​: This command is used to display the contents of a file. For example, to display the contents of a file named "file1.txt", you would type cat file1.txt.
  10. grep​: This command is used to search for specific patterns in files. For example, to search for the word "error" in a file named "log.txt", you would type grep "error" log.txt.

These are just a few basic Unix commands to get you started. Practice using them in a Unix terminal to become more familiar with them.

ls

The ls command is used to list directory contents.

Options:

  • -l: Long listing format
  • -a: Include hidden files
  • -h: Human-readable file sizes

Usage:

  • ls -l: List files in long format
  • ls -a: List all files including hidden files
  • ls -lh: List files with human-readable file sizes

cp

The cp command is used to copy files and directories.

Options:

  • -r: Copy directories recursively
  • -i: Prompt before overwriting

Usage:

  • cp file1 file2: Copy file1 to file2
  • cp -r dir1 dir2: Copy directory dir1 to dir2 recursively
  • cp -i file1 dir1: Copy file1 to directory dir1 with prompt before overwriting

chmod

The chmod command is used to change file permissions.

Options:

  • u: User
  • g: Group
  • o: Others
  • +: Add permission
  • -: Remove permission

Usage:

  • chmod u+r file: Add read permission for the user
  • chmod g-w file: Remove write permission for the group
  • chmod o+x file: Add execute permission for others

chown

The chown command is used to change file ownership.

Options:

  • -R: Change ownership recursively

Usage:

  • chown user:group file: Change ownership of file to user and group
  • chown -R user:group directory: Change ownership of directory and its contents recursively

rm

The rm command is used to remove files and directories.

Options:

  • -r: Remove directories and their contents recursively
  • -f: Force removal without confirmation

Usage:

  • rm file: Remove file
  • rm -r directory: Remove directory and its contents
  • rm -rf directory: Forcefully remove directory and its contents

mv

The mv command is used to move or rename files and directories.

Options:

  • -i: Prompt before overwriting

Usage:

  • mv file1 file2: Move file1 to file2
  • mv file newname: Rename file to newname
  • mv -i file directory: Move file to directory with prompt before overwriting

ssh

The ssh command is used to securely connect to a remote server.

Options:

  • -p: Specify port number
  • -i​: Specify private key file

Usage:

  • ssh user@hostname: Connect to a remote server
  • ssh -p port user@hostname: Connect to a remote server on a specific port

scp

The scp command is used to securely copy files between hosts.

Options:

  • -r: Copy directories recursively

Usage:

  • scp file user@hostname:/path/to/destination: Copy file to a remote server
  • scp -r directory user@hostname:/path/to/destination: Copy directory to a remote server recursively

netstat

The netstat command is used to display network connections, routing tables, and interface statistics.

Options:

  • -t: Display TCP connections
  • -u: Display UDP connections
  • -n: Display numerical addresses

Usage:

  • netstat -t: Display TCP connections
  • netstat -u: Display UDP connections
  • netstat -n: Display numerical addresses

sudo

The sudo command is used to execute commands with superuser privileges.

Usage:

  • sudo command: Execute command with superuser privileges

grep

The grep command is used to search for patterns in files.

Options:

  • -i: Ignore case
  • -r: Recursively search in directories

Usage:

  • grep pattern file: Search for pattern in file
  • grep -i pattern file: Search for pattern in file ignoring case
  • grep -r pattern directory: Recursively search for pattern in directory

awk

The awk command is used for text processing and pattern matching.

Usage:

  • awk '{print $1}' file: Print the first column of a file
  • awk '/pattern/' file: Print lines matching a pattern in a file

sed

The sed command is used for text stream editing.

Usage:

  • sed 's/pattern/replacement/' file: Replace pattern with replacement in a file
  • sed '/pattern/d' file: Delete lines matching a pattern in a file

curl

The curl command is used to transfer data with URLs.

Usage:

  • curl https://example.com: Download content from a URL
  • curl -O https://example.com/file: Download a file from a URL

wget

The wget command is used to download files from the web.

Usage:

  • wget https://example.com/file: Download a file from a URL
  • wget -r https://example.com: Download recursively from a URL

tail

The tail command is used to display the last part of a file.

Options:

  • -n: Number of lines to display

Usage:

  • tail file: Display the last 10 lines of a file
  • tail -n 20 file: Display the last 20 lines of a file

less

The less command is used to view file contents page by page.

Usage:

  • less file: View file contents page by page
  • less +F file: View file contents and follow the end of the file

These are just a few of the basic Linux commands that every sysadmin should be familiar with. By mastering these commands and their options, you can efficiently manage and troubleshoot Linux systems. Practice using these commands in different scenarios to enhance your skills as a system administrator and more.


Hope you find this helpful!!!

Unix commands for beginner IT professional.
Ram Krishna April 20, 2024
Share this post
Our blogs
Sign in to leave a comment
Network Scanning with Nmap: Beginner Guide for Cybersecurity Professionals