Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the commands commonly used in Linux system

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article introduces the relevant knowledge of "what are the common commands in the Linux system?" in the operation of actual cases, many people will encounter such a dilemma, and then let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

System information

Processor Architecture of arch display Machine (1)

Processor Architecture of uname-m display Machine (2)

Uname-r shows the kernel version in use

Dmidecode-Q display hardware system components-(SMBIOS / DMI)

Hdparm-I / dev/hda lists the architectural features of a disk

Hdparm-tT / dev/sda performs testable read operations on disk

Cat / proc/cpuinfo displays the information of CPU info

Cat / proc/interrupts display interrupt

Cat / proc/meminfo verifies memory usage

Cat / proc/swaps shows which swap is used

Cat / proc/version shows the kernel version

Cat / proc/net/dev display Network Adapter and Statistics

Cat / proc/mounts displays the loaded file system

Lspci-tv lists PCI devices

Lsusb-tv display USB device

Date displays the system date

Cal 2007 displays the calendar for 2007

Date 041217002007.00 sets the date and time-month, day, hour, year. Second

Clock-w saves time changes to BIOS

Shutdown (shutdown, restart and logout of the system)

Shutdown-h now shuts down the system (1)

Init 0 shuts down the system (2)

Telinit 0 shuts down the system (3)

Shutdown-h hours:minutes & shuts down the system at the scheduled time

Shutdown-c cancels shutting down the system at the scheduled time

Shutdown-r now restart (1)

Reboot restart (2)

Logout logout

Files and directories

Cd / home enter the'/ home' directory'

Cd.. Return to the previous directory

Cd.. /.. Return to the upper two-level directory

Cd enters the personal home directory

Cd ~ user1 enters the personal home directory

Cd-returns the directory where it was last located

Pwd displays the work path

Ls view the files in the directory

Ls-F View the files in the directory

Ls-l displays the details of files and directories

Ls-a shows hidden files

Ls * [0-9] * displays file and directory names that contain numbers

Tree displays the tree structure of files and directories starting from the root directory (1)

Lstree displays the tree structure of files and directories starting from the root directory (2)

Mkdir dir1 creates a directory called 'dir1''

Mkdir dir1 dir2 creates two directories at the same time

Mkdir-p / tmp/dir1/dir2 create a directory tree

Rm-f file1 deletes a file called 'file1''

Rmdir dir1 deletes a directory called 'dir1''

Rm-rf dir1 deletes a directory called 'dir1' and deletes its contents at the same time

Rm-rf dir1 dir2 deletes both directories and their contents

Mv dir1 new_dir rename / move a directory

Cp file1 file2 copies a file

Cp dir/*. Copy all files in a directory to the current working directory

Cp-a / tmp/dir1. Copy a directory to the current working directory

Cp-a dir1 dir2 copy a directory

Ln-s file1 lnk1 creates a soft link to a file or directory

Ln file1 lnk1 creates a physical link to a file or directory

Touch-t 0712250000 file1 modifies the timestamp of a file or directory-(YYMMDDhhmm)

File file1 outputs the mime type of the file as text

Iconv-l lists known codes

Iconv-f fromEncoding-t toEncoding inputFile > outputFile creates a new from the given input file by assuming it is encoded in fromEncoding and converting it to toEncoding.

Find. -maxdepth 1-name * .jpg-print-exec convert "{}"-resize 80x60 "thumbs/ {}"\; batch resize files in the current directory and send them to a thumbnails directory (requires convert from Imagemagick)

File search

Find /-name file1 enters the root file system from'/'to search for files and directories

Find /-user user1 searches for files and directories belonging to user 'user1'

Find / home/user1-name\ * .bin searches for files ending with '.bin' in the directory'/ home/user1''

Find / usr/bin-type f-atime + 100 searches for execution files that have not been used in the past 100 days

Find / usr/bin-type f-mtime-10 searches for files that have been created or modified within 10 days

Find /-name\ * .rpm-exec chmod 755'{}'\; search for files ending with '.rpm' and define their permissions

Find /-xdev-name\ * .rpm searches for files ending in '.rpm' and ignores removable devices such as CD-ROMs and Agile drives

Locate\ * .ps looks for files that end with '.ps'-run the 'updatedb' command first

Whereis halt shows the location of a binary, source, or man

Which halt displays the full path to a binary or executable file

Mount a file system

Mount / dev/hda2 / mnt/hda2 mount a disk called hda2-make sure the directory'/ mnt/hda2' already exists

Umount / dev/hda2 unmount a disk called hda2-exit from mount point'/ mnt/hda2' first

Fuser-km / mnt/hda2 force uninstall when the device is busy

Umount-n / mnt/hda2 runs the uninstall operation without writing to the / etc/mtab file-useful when the file is read-only or when the disk is full

Mount / dev/fd0 / mnt/floppy mount a floppy disk

Mount / dev/cdrom / mnt/cdrom mount a cdrom or dvdrom

Mount / dev/hdc / mnt/cdrecorder mount a cdrw or dvdrom

Mount / dev/hdb / mnt/cdrecorder mount a cdrw or dvdrom

Mount-o loop file.iso / mnt/cdrom mounts a file or ISO image file

Mount-t vfat / dev/hda5 / mnt/hda5 mounts a Windows FAT32 file system

Mount / dev/sda1 / mnt/usbdisk mounts a usb shortcut or flash memory device

Mount-t smbfs-o username=user,password=pass / / WinClient/share / mnt/share mounts a windows network share

Disk space

Df-h displays a list of mounted partitions

Ls-lSr | more arranges files and directories by size

Du-sh dir1 estimates the directory 'disk space already used by dir1''

Du-sk * | sort-rn displays the size of files and directories in turn based on capacity

Rpm-Q-a-- qf'{SIZE} t% {NAME} n' | sort-K1Power1n displays the space used by installed rpm packages in turn based on size (fedora, redhat systems)

Dpkg-query-W-fallow packages ${Installed-Size;10} t ${Package} n' | sort-K1Magin1n displays the space used by installed deb packages based on size (ubuntu, debian systems)

Return to the top index ^

Users and groups

Groupadd group_name creates a new user group

Groupdel group_name deletes a user group

Groupmod-n new_group_name old_group_name rename a user group

Useradd-c "Name Surname"-g admin-d / home/user1-s / bin/bash user1 creates a user belonging to the "admin" user group

Useradd user1 creates a new user

Userdel-r user1 deletes a user ('- r 'excludes home directory)

Usermod-c "User FTP"-g system-d / ftp/user1-s / bin/nologin user1 modify user attributes

Passwd change password

Passwd user1 modifies a user's password (only root is allowed to execute)

Chage-E 2005-12-31 user1 sets the expiration period for user passwords

Pwck checks the file format and syntax correction of'/ etc/passwd''as well as the presence of users

Grpck checks the file format and syntax correction of'/ etc/passwd''as well as existing groups

Newgrp group_name logs in to a new group to change the default group of newly created files

This is the end of the content of "what are the common commands in the Linux system?" Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report