Linux

Linux

insert image description here

Linux is a free and open source UNIX-like operating system. It runs major Unix utilities, applications, and network protocols, and supports 32-bit and 64-bit hardware. The operating system's kernel was first released on October 5, 1991 by Linus Torvalds.
Linux started as a free operating system for personal computers supporting Intel's x86 architecture and now runs on servers and other large platforms such as mainframes and supercomputers. Linux is also widely used in embedded systems, such as mobile phones (Mobile Phone), tablet computers (Tablet), routers (Router), television (TV) and electronic game consoles.

Common Commands in Linux

insert image description here

system info
arch show the machine's processor architecture
uname -m show the machine's processor architecture
uname -r show the kernel version in use
dmidecode -q show the hardware system components - (SMBIOS / DMI)
hdparm -i /dev/hda list a disk Architectural features of
hdparm -tT /dev/sda Perform a test read operation on disk
cat /proc/cpuinfo Display CPU info information
cat /proc/interrupts Display interrupts
cat /proc/meminfo Verify memory using
cat /proc/swaps Show which swap is used
cat /proc/version Show kernel version
cat /proc/net/dev Show network adapters and statistics
cat /proc/mounts Show mounted filesystems
lspci -tv List PCI devices
lsusb -tv Show USB device
date Display system date
cal 2007 Display 2007 calendar
date 041217002007.00 Set date and time - month day hour minute year. second
clock -w save time modification to BIOS

Shutdown (shutdown, restart and logout of the system)
shutdown -h now Shut down the system
init 0 Shut down the system
telinit 0 Shut down the system
shutdown -h hours:minutes & Shut down the system according to the scheduled time
shutdown -c Cancel shutdown the system according to the scheduled time
shutdown -r now restart
reboot restart
logout logout

Files and directories
cd /home Enter the '/home' directory '
cd … return to the previous directory
cd …/… Return to the previous directory
cd enter the personal home directory
cd ~user1 enter the personal home directory
cd - return to the last location directory
pwd show working path
ls view files in a directory
ls -F view files in a directory
ls -l show details of files and directories
ls -a show hidden files
ls [0-9] show file and directory names containing numbers
tree show the tree structure
of files and directories starting from the root directory lstree show the tree structure of files and directories starting from the root directory
mkdir dir1 create a directory called 'dir1' '
mkdir dir1 dir2 create two directories at the same time
mkdir -p /tmp/ dir1/dir2 create a directory tree
rm -f file1 delete a file called 'file1'
rmdir dir1 delete a directory called 'dir1'
rm -rf dir1 delete a directory called 'dir1' and delete its contents
rm - rf dir1 dir2 delete both directories and their contents at the same time
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 Softlinks
ln file1 lnk1 Create a physical link to a file or directory
touch -t 0712250000 file1 Modify timestamp of a file or directory - (YYMMDDhhmm)
file file1 outputs the mime type of the file as text
iconv -l List known The encoding
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 enter root file system starting from '/' search files and directories
find / -user user1 search files and directories belonging to user 'user1'
find /home/user1 -name *.bin in directory '/home' Search for files ending in '.bin' in /user1'
find /usr/bin -type f -atime +100 Search for executable files that have not been used in the last 100 days
find /usr/bin -type f -mtime -10 search for files 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 search Files ending with '.rpm' ignore removable devices such as CD-ROM, USB, etc.
locate *.ps Look for files ending with '.ps' - run the 'updatedb' command
whereis halt to display the location of a binary file, source code or man
which halt displays the full path to a binary or executable

mount a filesystem
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 - start with the mount point' /mnt/hda2' Exit
fuser -km /mnt/hda2 Force unmount when device is busy
umount -n /mnt/hda2 Run unmount operation without writing to /etc/mtab file - when file is read-only or when disk is full very useful
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 mounts 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 mount a USB flash drive or flash device
mount -t smbfs -o username=user,password=pass //WinClient/share /mnt/share mount a windows network share

disk space
df -h show mounted partition list
ls -lSr |more arrange files and directories by size
du -sh dir1 estimate disk space used by directory 'dir1'
du -sk * | sort -rn by size In order to display the size of files and directories in order
rpm -q -a --qf '%10{SIZE}t%{NAME}n' | sort -k1,1n Display the installed rpm packages in order based on size Space (fedora, redhat-like system)
dpkg-query -W -f=' I nstalled − S ize ; 10 t {Installed-Size;10}tInstalledSize;1 0 t {Package}n' | sort -k1,1n Display the space used by installed deb packages (ubuntu, debian-like systems) by size

users and groups
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
useradd user1 belonging to the "admin" user group 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 Modify password
passwd user1 Modify a user's password (only root is allowed to execute)
chage -E 2005-12-31 user1 Set user password expiration period
pwck Check the file format of '/etc/passwd' and syntax correction and existing user
grpck check '/etc/passwd' for file format and syntax correction and existing group
newgrp group_name login into a new group to change the default group for newly created files

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324103679&siteId=291194637