,

100 command lines in Linux useful for newbie

Posted by

Certainly! Here’s an extended list of 100 useful command lines in Linux for newcomers:

File and Directory Operations

  1. ls: List files and directories in the current location.
  2. ls -l: List files and directories in long format.
  3. ls -a: List all files and directories, including hidden ones.
  4. cd: Change directory.
  5. cd ..: Go up one directory level.
  6. pwd: Print the current working directory.
  7. mkdir directory_name: Create a new directory.
  8. rm file_name: Remove a file.
  9. rm -r directory_name: Remove a directory and its contents recursively.
  10. cp source_file destination_file: Copy a file.
  11. cp -r source_directory destination_directory: Copy a directory and its contents recursively.
  12. mv source_file destination_file: Move or rename a file.
  13. mv directory_name destination_directory: Move a directory.
  14. cat file_name: Display the contents of a file.
  15. less file_name: View the contents of a file interactively.
  16. head file_name: Display the first few lines of a file.
  17. tail file_name: Display the last few lines of a file.
  18. grep pattern file_name: Search for a pattern in a file.
  19. find directory -name file_name: Search for files in a directory based on their names.
  20. chmod permissions file_name: Change permissions of a file.
  21. chmod -R permissions directory_name: Change permissions recursively for a directory and its contents.
  22. chown user_name file_name: Change the owner of a file.
  23. chown -R user_name directory_name: Change the owner recursively for a directory and its contents.
  24. tar -czvf archive_name.tar.gz directory_name: Create a compressed archive of a directory.
  25. tar -xzvf archive_name.tar.gz: Extract files from a compressed archive.

Text Processing

  1. echo "text": Print text to the console.
  2. echo $variable: Print the value of a variable.
  3. wc file_name: Count the number of lines, words, and characters in a file.
  4. sort file_name: Sort lines in a file alphabetically.
  5. uniq file_name: Remove adjacent duplicate lines from a sorted file.
  6. cut -d delimiter -f field file_name: Extract specific fields from a delimited file.
  7. head -n N file_name: Display the first N lines of a file.
  8. tail -n N file_name: Display the last N lines of a file.
  9. sed 's/old_text/new_text/' file_name: Replace occurrences of old_text with new_text in a file.
  10. awk '{print $1}' file_name: Print the first column of a file using the AWK command.
  11. grep pattern file_name: Search for a pattern in a file.
  12. grep -r pattern directory_name: Search for a pattern recursively in files within a directory.
  13. diff file1 file2: Show the differences between two files.
  14. paste file1 file2: Merge lines from two files side by side.

File Permissions

  1. ls -l: List files and directories with detailed permissions.
  2. chmod permissions file_name: Change permissions of a file.
  3. chmod -R permissions directory_name: Change permissions recursively for a directory and its contents.
  4. chown user_name file_name: Change the owner of a file.
  5. chown -R user_name directory_name: Change the owner recursively for a directory and its contents.

Networking

  1. ping host: Send ICMP echo requests to a host.
  2. wget url: Download a file from the web.
  3. curl url: Retrieve the content of a URL.
  4. ifconfig: Display network interface information.
  5. ip addr show: Display IP address information.
  6. netstat: Display network connections and statistics.
  7. ssh user@host: Connect to a remote server using SSH.

System Information

  1. uname -a: Display system information.
  2. uptime: Show system uptime.
  3. whoami: Display the current user.
  4. who: Display currently logged-in users.
  5. df: Show disk space usage of file systems.
  6. du -sh directory_name: Estimate the disk usage of a directory.
  7. free: Display memory usage.
  8. top: Display real-time system resource usage.
  9. ps: Show running processes.
  10. kill process_id: Terminate a process.

Compression and Archiving

  1. gzip file_name: Compress a file using gzip.
  2. gunzip file_name: Decompress a gzip-compressed file.
  3. tar -czvf archive_name.tar.gz directory_name: Create a compressed tar archive.
  4. tar -xzvf archive_name.tar.gz: Extract files from a tar archive.

Package Management

  1. apt update: Update package lists.
  2. apt upgrade: Upgrade installed packages.
  3. apt install package_name: Install a package.
  4. apt remove package_name: Remove a package.
  5. apt search package_name: Search for a package.
  6. apt show package_name: Display information about a package.

Process Management

  1. ps: Show running processes.
  2. top: Display real-time system resource usage.
  3. kill process_id: Terminate a process.
  4. killall process_name: Terminate all instances of a process.

User and Group Management

  1. useradd username: Create a new user.
  2. userdel username: Delete a user.
  3. passwd username: Change the password for a user.
  4. groupadd groupname: Create a new group.
  5. groupdel groupname: Delete a group.
  6. usermod -aG groupname username: Add a user to a group.

System Maintenance

  1. reboot: Reboot the system.
  2. shutdown: Shut down the system.
  3. sudo command: Run a command with administrative privileges.
  4. history: View command history.
  5. clear: Clear the terminal screen.

File Transfer (FTP)

  1. ftp host: Connect to an FTP server.
  2. get file_name: Download a file from the FTP server.
  3. put file_name: Upload a file to the FTP server.
  4. ls: List files and directories on the FTP server.

Miscellaneous

  1. date: Display the current date and time.
  2. cal: Display a calendar.
  3. watch command: Execute a command repeatedly and display the output in real-time.
  4. man command: Display the manual page of a command.
  5. history: View command history.
  6. clear: Clear the terminal screen.
  7. exit: Exit the current shell.
  8. alias name="command": Create an alias for a command.
  9. echo $PATH: Display the value of the PATH environment variable.
  10. Ctrl+C: Interrupt the currently running command.

These commands cover a wide range of tasks and should help you navigate the Linux command line effectively. Remember to refer to the

manual pages (man command) for more detailed information on specific commands and their options.