Frequently used Ubuntu commands

1. ls

Lists the contents of a directory.

  • ls - Lists files and directories in the current directory.
  • ls -l - Lists with detailed information including permissions, owner, size, and modification date.
  • ls -a - Lists all entries including hidden files starting with ..

2. cd

Changes the current directory.

  • cd /path/to/directory - Changes to the specified directory.
  • cd .. - Moves up one directory level.
  • cd or cd ~ - Changes to the user's home directory.

3. pwd

Prints the current working directory.

  • pwd - Outputs the full path of the current directory.

4. cp

Copies files or directories.

  • cp source_file destination_file - Copies a file.
  • cp -r source_directory destination_directory - Recursively copies a directory.

5. mv

Moves or renames files and directories.

  • mv source destination - Moves or renames files or directories.

6. rm

Removes files or directories.

  • rm file - Deletes a file.
  • rm -r directory - Recursively deletes a directory and its contents.

7. mkdir

Creates a new directory.

  • mkdir directory_name - Creates a new directory.

8. rmdir

Removes empty directories.

  • rmdir directory_name - Removes an empty directory.

9. chmod

Changes the permissions of files or directories.

  • chmod 755 file - Changes the permissions of a file to read, write, and execute for the owner, and read and execute for others.

10. chown

Changes the owner and/or group of files or directories.

  • chown user:group file - Changes the owner and group of a file.

11. top

Displays running processes and system resource usage.

  • top - Opens an interactive monitor displaying system processes and resource usage.

12. df

Shows disk space usage.

  • df - Shows the amount of disk space used and available on all mounted filesystems.
  • df -h - Displays the space in human-readable form (e.g., KB, MB, GB).

13. du

Shows the disk usage of files and directories.

  • du -sh directory - Shows the total size of a directory in a human-readable format.

14. grep

Searches for patterns in text.

  • grep "pattern" file - Searches for a pattern within a file and prints lines containing the pattern.

15. echo

Displays a line of text/string that is passed as an argument.

  • echo "Hello, World!" - Prints "Hello, World!" to the terminal.

16. cat

Concatenates and displays files.

  • cat file - Displays the contents of a file.

17. tail

Displays the last part of files.

  • tail file - Shows the last 10 lines of a file.
  • tail -f file - Continuously monitors the end of a file, useful for logs.

18. head

Displays the first part of files.

  • head file - Shows the first 10 lines of a file.

19. man

Displays the manual pages for commands.

  • man command - Shows the manual for the specified command.

20. sudo

Executes a command with superuser privileges.

  • sudo command - Executes the command as the superuser.

These commands form the backbone of the Ubuntu command-line interface and are critical for daily operations and system management. Each command typically has a man page (e.g., man ls) which provides detailed usage information, options, and examples.

相关推荐
bohu832 小时前
亚博microros小车-原生ubuntu支持系列:16 机器人状态估计
ubuntu·机器人·imu·localization·microros·imu_tools
马立杰3 小时前
H3CNE-33-BGP
运维·网络·h3cne
云空4 小时前
《DeepSeek 网页/API 性能异常(DeepSeek Web/API Degraded Performance):网络安全日志》
运维·人工智能·web安全·网络安全·开源·网络攻击模型·安全威胁分析
深度Linux4 小时前
Linux网络编程中的零拷贝:提升性能的秘密武器
linux·linux内核·零拷贝技术
没有名字的小羊5 小时前
Cyber Security 101-Build Your Cyber Security Career-Security Principles(安全原则)
运维·网络·安全
千夜啊5 小时前
Nginx 运维开发高频面试题详解
运维·nginx·运维开发
存储服务专家StorageExpert6 小时前
答疑解惑:如何监控EMC unity存储系统磁盘重构rebuild进度
运维·unity·存储维护·emc存储
chian-ocean8 小时前
从理论到实践:Linux 进程替换与 exec 系列函数
linux·运维·服务器
拎得清n8 小时前
UDP编程
linux
敖行客 Allthinker8 小时前
从 UTC 日期时间字符串获取 Unix 时间戳:C 和 C++ 中的挑战与解决方案
linux·运维·服务器·c++