Linux most used Commands

From Pulsed Media Wiki

200 Commonly Used Debian Linux Commands

Navigation and File Management

  • pwd – Print current working directory
  • cd [dir] – Change directory
  • ls – List directory contents
  • ls -l – Long listing format
  • ls -a – List all files including hidden
  • mkdir [dir] – Create a new directory
  • rmdir [dir] – Remove empty directory
  • rm [file] – Remove file
  • rm -r [dir] – Remove directory and contents
  • cp [src] [dest] – Copy file or directory
  • mv [src] [dest] – Move or rename file or directory
  • touch [file] – Create empty file or update timestamp
  • find [path] -name [name] – Search for files
  • locate [file] – Find files using database
  • updatedb – Update the file database for locate
  • stat [file] – Display file status
  • file [file] – Determine file type
  • basename [path] – Extract filename from path
  • dirname [path] – Extract directory from path
  • tree – Display directory structure in tree format

Viewing and Editing Files

  • cat [file] – Concatenate and display file content
  • less [file] – View file content page by page
  • more [file] – View file content page by page
  • head [file] – Display first lines of a file
  • tail [file] – Display last lines of a file
  • nano [file] – Edit file with nano editor
  • vim [file] – Edit file with Vim editor
  • gedit [file] – Edit file with Gedit GUI editor
  • diff [file1] [file2] – Compare files line by line
  • cmp [file1] [file2] – Compare files byte by byte
  • wc [file] – Count lines, words, and bytes
  • cut -d [delim] -f [field] [file] – Extract fields from lines
  • sort [file] – Sort lines in a file
  • uniq [file] – Filter duplicate lines
  • tr [set1] [set2] – Translate characters
  • sed [options] [file] – Stream editor for filtering and transforming text
  • awk [pattern] [file] – Pattern scanning and processing language

File Compression and Archiving

  • tar -cvf [archive.tar] [files] – Create tar archive
  • tar -xvf [archive.tar] – Extract tar archive
  • tar -czvf [archive.tar.gz] [files] – Create compressed tar.gz archive
  • tar -xzvf [archive.tar.gz] – Extract tar.gz archive
  • gzip [file] – Compress file
  • gunzip [file.gz] – Decompress file
  • bzip2 [file] – Compress file using bzip2
  • bunzip2 [file.bz2] – Decompress bzip2 file
  • xz [file] – Compress file using xz
  • unxz [file.xz] – Decompress xz file
  • zip [archive.zip] [files] – Create zip archive
  • unzip [archive.zip] – Extract zip archive
  • rar a [archive.rar] [files] – Create rar archive
  • unrar x [archive.rar] – Extract rar archive
  • 7z a [archive.7z] [files] – Create 7z archive
  • 7z x [archive.7z] – Extract 7z archive

Package Management (APT)

  • apt update – Update package lists
  • apt upgrade – Upgrade all packages
  • apt install [package] – Install package
  • apt remove [package] – Remove package
  • apt purge [package] – Remove package and configuration files
  • apt autoremove – Remove unnecessary packages
  • apt search [package] – Search for a package
  • apt show [package] – Display package details
  • apt list --installed – List installed packages
  • apt list --upgradable – List upgradable packages
  • dpkg -i [package.deb] – Install .deb package
  • dpkg -r [package] – Remove package
  • dpkg -l – List installed packages
  • dpkg -s [package] – Show package status
  • dpkg -L [package] – List files installed by package
  • dpkg -S [file] – Find package owning file
  • apt-cache depends [package] – Show package dependencies
  • apt-cache rdepends [package] – Show reverse dependencies
  • apt-mark hold [package] – Hold package at current version
  • apt-mark unhold [package] – Remove hold on package

Process Management

  • ps aux – Show all running processes
  • top – Display real-time process information
  • htop – Interactive process viewer
  • kill [PID] – Terminate process by PID
  • killall [name] – Terminate processes by name
  • nice [command] – Run command with adjusted priority
  • renice [PID] [priority] – Change priority of running process
  • jobs – List background jobs
  • fg [job] – Bring job to foreground
  • bg [job] – Resume job in background
  • nohup [command] & – Run command immune to hangups
  • watch [command] – Execute command periodically

User Management

  • adduser [user] – Add new user
  • useradd [user] – Add new user
  • passwd [user] – Change user password
  • deluser [user] – Delete user
  • usermod [options] [user] – Modify user account
  • groupadd [group] – Add new group
  • groupdel [group] – Delete group
  • groupmod [options] [group] – Modify group
  • groups [user] – Show user's groups
  • id [user] – Show user ID and group ID
  • who – Show who is logged in
  • whoami – Show current user
  • su [user] – Switch user
  • sudo [command] – Execute command as another