Linux Shell Commands - Part 1

January 29, 2024

Embarking on your journey with Linux, especially with a distribution like Ubuntu, introduces you to a powerful command-line interface (CLI) that can significantly enhance your productivity and understanding of the system. Here's a curated list of essential Linux commands, including both built-in and installable ones, that are invaluable to learn in your first two weeks. This list covers file management, system information, networking, and package management, providing a solid foundation for beginners.

File and Directory Management

  • ls (list directory contents)
    • Example: ls -l /home (lists files in /home with detailed information)
  • cd (change directory)
    • Example: cd /var/www (changes the current directory to /var/www)
  • mkdir (make directory)
    • Example: mkdir new_folder (creates a new directory named new_folder)
  • rmdir (remove directory)
    • Example: rmdir old_folder (removes the directory named old_folder)
  • touch (create a blank file)
    • Example: touch example.txt (creates a blank file named example.txt)
  • rm (remove files or directories)
    • Example: rm unwanted.txt (removes the file named unwanted.txt)
  • cp (copy files or directories)
    • Example: cp source.txt destination.txt (copies source.txt to destination.txt)
  • mv (move or rename files or directories)
    • Example: mv oldname.txt newname.txt (renames or moves a file)

System Information and Management

  • top (display active processes)
    • Example: top (shows a dynamic view of running processes)
  • htop (interactive process viewer, may require installation)
    • Example: htop (provides a detailed overview of system processes)
  • df (report file system disk space usage)
    • Example: df -h (displays disk space in a human-readable format)
  • free (display memory usage)
    • Example: free -m (shows the amount of free and used memory in megabytes)
  • uname (show system information)
    • Example: uname -a (displays all system information)

Networking

  • ping (check the network connection to a server)
    • Example: ping google.com (checks connectivity to google.com)
  • ifconfig (configure network interfaces, may require installation)
    • Example: ifconfig (displays network interfaces and IP addresses)
  • netstat (network statistics)
    • Example: netstat -tuln (lists all tcp and udp ports listening for connections)
  • wget (retrieve files from the web)
    • Example: wget http://example.com/file.zip (downloads file.zip from example.com)

Package Management (Ubuntu/Debian)

  • apt-get (package handling utility)
    • Example: sudo apt-get update (updates package lists for upgrades)
    • Example: sudo apt-get install htop (installs the htop package)
  • dpkg (Debian package management system)
    • Example: dpkg -l (lists all installed packages)

Text File Viewing and Editing

  • cat (concatenate files and print on the standard output)
    • Example: cat file.txt (displays the content of file.txt)
  • nano (easy-to-use text editor)
    • Example: nano file.txt (opens file.txt in nano for editing)
  • grep (search text using patterns)
    • Example: grep "search term" file.txt (searches for "search term" within file.txt)

Miscellaneous

  • chmod (change file mode bits)
    • Example: chmod +x script.sh (makes script.sh executable)
  • man (manual pages for commands)
    • Example: man ls (displays the manual page for the ls command)
  • echo (display a line of text)
    • Example: echo "Hello, World!" (prints Hello, World! to the terminal)

Learning these commands provides a strong foundation for navigating and managing your Linux environment efficiently. Practice regularly and refer to the man pages for more detailed information and options available for each command.