Linux common command Daquan

  
        

System Information arch Shows the processor architecture of the machine (1) uname -m shows the processor architecture of the machine (2) uname -r shows the kernel version being used dmidecode -q shows the hardware system components - (SMBIOS /DMI) hdparm -i /dev/hda Lists the architectural characteristics of a disk hdparm -tT /dev/sda Performs a test read operation on disk cat /proc/cpuinfo Displays information about CPU info cat /proc/interrupts shows interrupt cat /proc/meminfo Verify memory usage cat /proc/swaps shows which swaps are used cat /proc/version shows the kernel version cat /proc/net/dev shows network adapters and statistics cat /proc/mounts shows loaded filesystems lspci -tv PCI device lsusb -tv Display USB device date Display system date cal 2007 Display 2007 calendar table date 041217002007.00 Set date and time - Month day, hour, year, second. clock -w Save time modification to BIOS shutdown (system shutdown, restart, and Logout)

shutdown -h now Shut down the system (1) init 0 Shut down the system (2) telinit 0 Shut down the system (3) shutdown -h hours:minutes & Shut down the system according to the scheduled time shutdown -c Cancel the system shutdown according to the scheduled time shutdown -r now Restart (1) reboot Restart (2) logout logout files and directories

cd /home Go to ‘/home’ Directory & rsquo; cd .. Return to the previous directory cd ../.. Return to the previous two levels cd Enter the personal home directory cd ~user1 Enter the personal home directory cd - Return to the last time The directory pwd shows the working path ls View the files in the directory ls -F View the files in the directory ls -l Display the details of the files and directories ls -a Show hidden files ls [0-9] Display the file name and directory name containing the numbers Tree Shows the tree structure of files and directories starting from the root directory (1) lstree shows the tree structure of files and directories starting from the root directory (2) mkdir dir1 creates a directory called ‘dir1’ & rsquo; mkdir dir1 dir2 is created at the same time Two directories mkdir -p /tmp/dir1/dir2 Create a directory tree rm -f file1 Delete a file called ‘file1’ & rsquo; rmdir dir1 Delete a file called ‘dir1’ Record & rsquo; rm -rf dir1 Delete a directory called & lsquo; dir1 & rsquo; and delete its contents at the same time rm -rf dir1 dir2 delete both directories and their contents mv dir1 new_dir rename /move a directory cp file1 file2 copy 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 Create a pointer to a file or directory Soft link ln file1 lnk1 Create a physical link to a file or directory touch -t 0712250000 file1 Change the timestamp of a file or directory - (YYMMDDhhmm) file file1 outputs the mime type of the file as text iconv -l List known The code 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 &ldquo ;{}” -resize 80x60 “thumbs/{}” \\; batch resize files in t He current directory and send them to a thumbnails directory (requires convert from Imagemagick) File Search

find /-name file1 Starts with ‘/’ and enters the root filesystem search file and directory find /-user user1 search Files and directories belonging to user ‘user1’ find /home/user1 -name *.bin Search for files ending with ’.bin’ in directory ‘/home/user1’ find /usr/bin -type f - Atime +100 Search for executable files that have not been used in the past 100 days find /usr/bin -type f -mtime -10 Search for files created or modified in 10 days find /-name *.rpm -exec chmod 755 &lsquo ;{}& rsquo; \\; Search for files ending with ‘.rpm’ and define their permissions find /-xdev -name *.rpm Search for files ending with ‘.rpm’, ignore mobile devices such as CD-ROMs, Jets, etc. Locate *.ps Find files ending with ‘.ps’ - Run first “updatedb’ Command whereis halt Display a binary file, source or man location which halt displays a binary Or full path to the executable User and group

groupadd group_name Create a new user group groupdel group_name Delete 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 Create a user belonging to the “admin” user group useradd user1 Create a new user userdel -r user1 Delete a user ( ‘-r’ exclude home directory) usermod -c “User FTP” -g system -d /ftp/user1 -s /bin/nologin user1 Modify user attributes passwd Change password passwd user1 Modify a user's password (only root is allowed) chage -E 2005-12-31 User1 sets the expiration period of the user password pwck checks the file format and syntax correction of ‘/etc/passwd’ and the existing user grpck check ‘/etc/passwd’ file format and syntax correction and the existing group newgrp group_name A new group to change the permissions of the newly created file's default group file - use &ldquo ;+” Set permissions, use “-” to cancel

ls -lh display permissions ls /tmp

Copyright © Windows knowledge All Rights Reserved