Skip to content
Home » Unix » Basic Unix Commands

Basic Unix Commands

Welcome to the world of Unix, a powerful operating system used in millions of computers worldwide. Unix, known for its robustness and versatility, is the backbone of many servers, workstations, and mobile devices. As a beginner, navigating through the Unix environment can seem daunting, but mastering the basic commands is your first step towards fluency. This guide is designed to introduce you to essential Unix commands, covering everything from file operations to system status checks and network management. With clear explanations and practical examples, you’ll gain the confidence to explore and operate within the Unix or Linux system efficiently. Whether you’re a system administrator, developer, or just a curious learner, these fundamental commands will lay the foundation for your Unix proficiency.

Getting Help in Unix

  • man <command>: View manual pages for commands.
    • Example: man ls
    • Example: man grep

Unix Shell Commands

  • clear: Clears the terminal screen.
  • history: Shows the command history.
    • Example: history | grep ls

Time and Date Commands

  • date: Shows the current date and time.
  • sleep <seconds>: Waits for a specified number of seconds.
    • Example: sleep 10
  • uptime: Shows system uptime.
    • Example: uptime -p

Unix Users Commands

  • whoami: Displays the current user’s username.
  • id: Shows user and group information.
    • Example: id -u
  • groups: Lists user’s groups.
  • passwd: Changes the user’s password.
  • who: Shows who is logged in.
    • Example: who -a
  • last: Shows the login history.
    • Example: last -n 10

Unix File Operations

  • ls: Lists directory contents.
    • Example: ls -l
    • Example: ls -a
  • cp: Copies files and directories.
    • Example: cp file.txt backup.txt
    • Example: cp -r folder/ new_folder/
  • rm: Removes files or directories.
    • Example: rm file.txt
    • Example: rm -rf folder/
  • mv: Moves or renames files or directories.
    • Example: mv file.txt newfile.txt
    • Example: mv folder/ new_location/
  • chmod: Changes file access permissions.
    • Example: chmod 755 script.sh
    • Example: chmod u+x script.sh
  • chown: Changes file or directory ownership.
    • Example: chown user file.txt
    • Example: chown user:group file.txt

Text File Operations in Unix

  • cat: Shows file contents.
    • Example: cat file.txt
  • more: Paginates text file viewing.
    • Example: more file.txt
  • less: An improved file viewer.
    • Example: less /var/log/syslog
  • head: Shows the first lines of a file.
    • Example: head -n 5 file.txt
  • tail: Shows the last lines of a file.
    • Example: tail -n 5 file.txt
  • grep: Searches for patterns in files.
    • Example: grep "pattern" file.txt
    • Example: grep -i "pattern" file.txt

Unix Directory Management Commands

  • cd: Changes the current directory.
    • Example: cd /var/log
  • pwd: Shows the current directory.
  • ln: Creates links to files or directories.
    • Example: ln -s /path/to/file link_name
  • mkdir: Creates new directories.
    • Example: mkdir new_folder
  • rmdir: Removes directories.
    • Example: rmdir empty_folder

Unix System Status Commands

  • hostname: Shows or sets the system hostname.
  • w: Displays system load and user activity.
  • uname: Shows system information.
    • Example: uname -a

Reboot Commands

  • shutdown: Gracefully shuts down the system.
    • Example: shutdown -h now
  • halt: Abruptly stops the system.
  • reboot: Reboots the system immediately.

Networking Commands in Unix

  • ifconfig: Manages network interfaces.
    • Example: ifconfig eth0
  • ip: Newer tool for network configuration.
    • Example: ip addr show
  • ping: Checks network connectivity.
    • Example: ping google.com
  • netstat: Displays network statistics.
    • Example: netstat -tuln

Process Management

  • ps: Lists running processes.
    • Example: ps aux
  • top: Shows real-time system status.
  • kill: Terminates processes.
    • Example: kill 1234
    • Example: kill -9 1234

Remote Access Commands

  • telnet: Insecure remote access protocol.
    • Example: telnet host.example.com
  • ssh: Secure shell for remote access.

File Transfers Commands

  • ftp: File transfer protocol client.
    • Example: ftp host.example.com
  • sftp: Secure version of FTP.
  • scp: Secure file copy.
  • wget: Downloads files from the web.
    • Example: wget http://example.com/file.txt

Leave a Reply

Your email address will not be published. Required fields are marked *