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.

相关推荐
wqqqianqian9 分钟前
国产linux系统(银河麒麟,统信uos)使用 PageOffice自定义Word模版中的数据区域
linux·word·自定义·pageoffice·数据区域
南棱笑笑生22 分钟前
20250512给NanoPi NEO core开发板在Ubuntu core20.04系统更新boot.img
linux·运维·ubuntu
XMYX-024 分钟前
Linux du 命令终极指南:从基础到精通
linux·服务器
小锋学长生活大爆炸40 分钟前
【教程】Docker更换存储位置
运维·docker·容器
DourPanda44 分钟前
polarctf-web-[rce1]
linux·网络协议·网络安全
愚润求学1 小时前
【Linux】动静态库链接原理
linux·运维·服务器·开发语言·笔记
云攀登者-望正茂2 小时前
无缝部署您的应用程序:将 Jenkins Pipelines 与 ArgoCD 集成
运维·jenkins·argocd
wingaso2 小时前
[经验总结]删除gitlab仓库分支报错:错误:无法推送一些引用到“http:”
linux·数据仓库·git
独行soc2 小时前
2025年渗透测试面试题总结-阿里云[实习]阿里云安全-安全工程师(题目+回答)
linux·经验分享·安全·阿里云·面试·职场和发展·云计算
勤不了一点2 小时前
小白上手RPM包制作
linux·运维·服务器·软件工程