Basic Linux Learning

Source: Internet
Author: User
Tags disk usage

Learn these commands to share: Search data within a text file

grep -n -e pattern1 -e pattern2 file1
-nThe search data shows the line number display
-e pattern1Multiple matching modes can be selected by this parameter, and the multiple relationships are any match.

Sort commands

sort -t ‘:‘ -k 3 -n /etc/passwd
-t ‘:‘ 按照冒号分割每行
-k 3Sort the data in the third column
-nThe sorted column data is converted to a numeric sort, which is sorted by string by default.

Hanging in the ISO file

mount -t iso9660 -o loop xxx.iso mnt
-t iso9660For mount type ISO file
-o loopTo mount a file

viewing file information

stat filenameViewing file statistics
file filenameView File types
cat -b filenameView file contents, text plus line number
lesss filenameExtended more commands, partial view file commands

Batch Kill Process

ps -ef | grep openvpn | grep -v grep| awk ‘{print $2}‘ | xargs sudo kill -9

Viewing host basic information

View operating system-related information uname -a
View Kernel version cat /proc/version
View Release version information cat /etc/issue
View disk usage and mount information df -h
Viewing network configuration informationifconfig

Port is occupied to resolve

To find a port that is occupied:
netstat -tln
netstat -tln | grep 8080

See which program the port belongs to
lsof -i :8080

Kill the process that occupies the port:
kill -9Process ID

Zip compression and decompression

Compress the ZIP package and zip -r yasuo.zip abc.txt dir1 compress the files and directories.
Unzip the ZIP package unzip yasuo.zip

Apt-get Program and System Management

Check for updates: Apt-get update
System Upgrade: Apt-get Upgrade
Removal software: apt-get remove xxx
Automatic removal of old packages: Apt-get Autoremove
Complete removal of packages (including configuration files, etc.): Apt-get purge xxx
Remove Package: Apt-get Clean
Use the combo command: the "&&" symbol allows multiple commands to be executed sequentially.

Boot up

The Debian system starts, edits /etc/rc.local , and adds a start command at the end of the script.
CentOS system boot up, add boot command to /etc/rc.d/rc.local file

The following commands are commonly used:
    1. man <command_name>  # 帮助命令

    2. ls    # 列出目录内容,`ls -al`

    3. pwd    # 在终端中显示当前工作目录的全路径。

    4. cd    # 要变更你当前所在的目录。

    5. mkdir    # 创建一个新的目录。

    6. cp    # 复制文件/重命名文件。

    7. mv    # 移动文件。

    8. find/locate    # 搜索文件。("find / -name filename")

    9. kill    # 快速关闭一个进程。

    10. passwd    # 更改密码。 -9 表示强迫进程立即停止

    11. md5sum    # 计算和检验MD5信息签名

    12. history    # 查询历史记录命令。

    13. sudo    # (super user do)命令允许授权用户执行超级用户或者其它用户的命令。

    14. touch    # 创建一个新文件,或者将文件的访问和修改时间更新为当前时间。

    15. chmod    #修改文件的访问权限。

    16. chown    # 改变文件拥有者和所在用户组。

    17. chkconfig --list | grep vsftpd    # 显示默认在哪个级别上启动

    18. chkconfig vsftpd on    # 添加服务到系统启动项

    19. ps -aux | grep fiefox    # 显示所有进程状态     -ef 查看进程信息

    20. netstat -tp    # 查看网络连接命令

    21. service --status-all    # 查看系统服务状态

    22. mount [-t vfstype] [-o options] device dir

    23. mount /dev/cdrom /home/sunky/mydisk.iso  # 挂在文件或设备到挂载点

    24. tail -100f /data/logs/resource_raw.tornado.log    # 在线查看日志

    25. whereis nginx    # 查找应用位置

    26. reboot  # 重启命令

    27. shutdown -r now  # 立刻重启

    28. shutdown -r 10  # 过10分钟自动重启

    29. shutdown -c  # 取消重启

    30. halt  # 关机命令

    31.  

Basic Linux Learning

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.