Basic Unix Commands

Knowing basic Unix commands should allow you to navigate your Unix or Linux system, confirm current system status and manage files or directories.

UPDATE 09/2024: I’ll be publishing a short video walkthrough of Basic Unix Commands here at the top of the page shortly.

Getting help in Unix

  • man – view manual pages for Unix commands

Unix Shell Commands

  • clear – clear screen
  • history – show history of previous commands

Time and Date commands

  • date – show current date and time
  • sleep – wait for a given number of seconds
  • uptime – find out how long the system has been up

Unix users commands

These commands allow you to get basic information about Unix users in your environment.

  • whoami – show your username
  • id – print user identity
  • groups – show which groups user belongs to
  • passwd – change user password
  • who – find out who is logged into the system
  • last – show history of logins into the system

Unix file operations

Navigating filesystem and managing files and access permissions:

  • ls – list files and directories
  • cp – copy files (work in progress)
  • rm – remove files and directories (work in progress)
  • mv – move or rename files and directories to another location
  • chmod – change file/directory access permissions
  • chown – change file/directory ownership

Text file operations in Unix

Most of important configuration in Unix is in clear text files, these commands will let you quickly inspect files or view logs:

  • cat – concatenate files and show contents to the standard output
  • more – basic pagination when viewing text files or parsing Unix commands output
  • less – an improved pagination tool for viewing text files (better than more command)
  • head – show the first 10 lines of text file (you can specify any number of lines)
  • tail – show the last 10 lines of text file (any number can be specified)
  • grep – search for patterns in text files

Unix directory management commands

Navigating filesystems and managing directories:

  • cd – change directory
  • pwd – confirm current directory
  • ln – make links and symlinks to files and directories
  • mkdir – make new directory
  • rmdir – remove directories in Unix

Unix system status commands

Most useful commands for reviewing hostname configuration and vital stats:

  • hostname – show or set server hostname
  • w – display system load, who’s logged in and what they are doing
  • uname – print Unix system information

Reboot

  • shutdown – graceful shutdown and reboot of your system
  • halt – ungraceful (without stopping OS services) shutdown
  • reboot – ungraceful reboot (without stopping OS services)

Networking commands in Unix

Most useful commands for inspecting network setup and exploring network connections and ports:

  • ifconfig – show and set IP addresses (found almost everywhere)
  • ip – show and set IP addresses (in recent Linux versions)
  • ping – check if remote host is reachable via ICMP ping
  • netstat – show network stats and routing information

Process management

Listing processes and confirming their status, and stopping processes if needed:

  • ps – list processes
  • top – show tasks and system status (check out htop as well)
  • kill – kill a process (stop application running)

Remote access commands

ssh is really the only way to go, but it’s important to know telnet as well:

  • telnet – clear-text (insecure) remote access protocol
  • ssh – Secure SHell – encrypted remote access client

File transfers commands

Always useful to know how to copy files between servers or just download some package from the web:

  • ftp – clear-text (insecure!) File Transfer Protocol client
  • sftp – secure (encrypted) version of FTP
  • scp – secure (encrypted) version of cp command
  • wget – download files from remote servers, HTTP/HTTPS and FTP
  • curl – download files from remote servers, HTTP/HTTPS and FTP

See Also




Contact Me

Follow me on Facebook, Twitter or Telegram:
Recommended
I learn with Educative: Educative
IT Consultancy
I'm a principal consultant with Tech Stack Solutions. I help with cloud architectrure, AWS deployments and automated management of Unix/Linux infrastructure. Get in touch!
Recent Articles
03 Sep 2024

macOS Sequoia 15.0

02 Sep 2024

Video: Has This Worked Before?

24 Mar 2024

Homelab: Mac Pro 2013 32GB

Recent Tweets