Linux Common Simple Command __linux

Source: Internet
Author: User
Tags chmod clear screen diff memory usage mkdir time and date rpmbuild

1.# represents a permission user (such as: root), and $ represents a normal user
power-on prompt Ogin: Enter user name
Password: Enter password user is the system registered user successful landing, you can enter the corresponding user environment.
Exit Current shell, enter: Exit

2.useradd netseek Add a Netseek user
passwd Netseek to Netseek This user to set a password.
(/etc/passwd/etc/group)
Userdel Netseek Delete Account
Userdel-r Netseek Delete account with your own directory.
[For more details, see man page, and account Admin]

3. View commands
Ls-l Display file list
LS-AL-A displays all files and directories (LS) the filename or directory name begins with "." As hidden files, not listed)
Ls-al |grep ' ^d ' Display directory
Ls-al |grep ' ^[^d] ' queries all files in a directory that do not contain a directory
Ls-sh (man ls to view Man help.)

Linux several file types:
D indicates that this file is a directory
-Indicates that this file is a normal file
b indicates that this file is a special block device I/o file
c indicates that this file is a special character device I/O file
L indicates that this file is a connection file. The path and name of the file immediately attached to it after its file name

The file command determines the type of files by probing the contents of the file

4. Create files and directories
Touch 1.txt
Cat > 2.txt (Create a file with a directional character, fill in the content, press Ctrl+d to save the content)
mkdir mywork Build mywork This directory

5. copy files or directories
CP filename1 Filename2
Cp-r dir1 DIR2 Replication Directory
CP-RF parameter f is to delete a target file that already exists without prompting
The cp-i parameters I and F, on the other hand, will be prompted to confirm the target file before overwriting the target file, which will be overwritten and be interactive copies.

6. Delete files and directories (delete files or directories can be done with RM)
RM 1.c//Delete 1.c this file
RM-RF (Force delete file or directory, do not prompt when deleting.)

7. Remove the catalogue or change the file name
MV [opitons] source file or directory destination file or directory
[Options] Main parameters
-I: interactive operation, if the MV operation will result in the existing target file overwrite, at this time the system asked whether to rewrite, ask the user to answer "y" or "n",
This prevents the file from being overwritten incorrectly.
-F: Disables interaction. If the MV operation is to overwrite an existing target file without giving any indication, the I parameter will no longer function when this parameter is specified.
MV Hello. /move the Hello directory or file to the next level.

8.alias Alias
Alias dir= ' ls-l ' enter Dir, which is actually equivalent to executing the LS-L


9. Control of permissions (RWX 421)
chmod +x hello.sh is assigned executable permissions.
(A detailed description of the control of permissions)
chmod Command Permission Modification usage: chmod a 8 binary number filename (rwx 421)
Eg:chmod u+x Filenmame only want to run for themselves, others can only read
Chown netseek.netseek mydir change user group


U: Representing the owner of the file
G: Representing the same group of users
O: Indicates other user
A: Represents all users
Opt is representative of the operation, can be:
+: Add a permission
-: Cancel a permission
=: give the given permission and revoke the original permission
and mode represents the right:
R: Readable 4
W: Can write 2
X: Executable 1


10.PWD Display current directory full path and change directory
CD Netseek into Netseek this directory
CD Exit current directory
Cd.. /go to the previous level directory.
CD-Back to previous directory
CD ~ Back to home directory

cat,more,less command.
To display the contents of a file, the two commands are different: Cat prints the contents of the file all the time, while the more is displayed.
Less can scroll up and down to view content.
Cat > 1.txt can fill in or copy content, press Ctrl+d to save
Cat 1.c
More 1.c
Head-n filename shows the contents of the nth line
Tail-n filename Displays the contents of the following n rows
Tail-n 20/var/log/message Displays the latest 20-line log

12. Set Linux time and date
Date command ("date MMDDHHMMYYYY.SS")
July 24, 2006 12:37, 30 seconds
Date 072412372006.30
Date-s 20:30:30 #设置系统时间为20:30:30
Date-s 2006-7-24 #设置系统时期为2006-7-24
Clock-r #对系统Bios中读取时间参数
Clock-w #将系统时间 (such as time set by date) to the BIOS

13. View find the file (Find,grep,awk more please refer to the man page or Shell Programming topic explanation)
Several introductions:
Find path-name filename
Find/etc-name named.conf
Locate tool to search for files by file name (to first establish an index database via UpdateDB)
Localte named.conf
Whereis is looking for a binary file and will also find its Help file
Which is similar to where it is, only the set of the environment variables we set in the path of the search;

14. Killing Process
PS aux
Ps-ef |grep
Kill-9
See which process consumes the most memory
Ps-aux|sort +5n

Put programs in front of the background to perform
CP file1 File2 &
& and Ctrl+z You can use & or ctrl+z to put commands in the background to perform.
FG is the program that will be put in the background and put back in the foreground.
Jobs

15.DD Command Backup
DD if= "Input_file" of= "Out_file" bs= "block_size" count= "number"
Parameters:
If: is the input file can be a device
Of: Is output file can also be a device
BS: Plan the size of a block, if not set, preset is 512bytes
Count: How many BS mean.

DD If=/etc/password Of=/tmp/passwd.bak Backup

16.mount load a hardware device
Usage: Mount [parameters] the device loading point to load
Eg:mount/dev/cdrom
Cd/mnt/cdrom//Enter CD directory
   U disk:
   mkdir/mnt/usb; (Note: Create mount directory)
   Mount/mnt/sda1/mnt/usb; (Note: Mount U disk)
   Now you can use the U disk, the contents of the/mnt/usb directory is the contents of the U disk;
   after use, to uninstall the U disk after the command.
   umount/mnt/usb
   mount     lists all the partitions of the system
   mount-t iso9660/dev/cdrom/mnt/cdrom   mount CD-ROM
   mount-t vfat/dev/fd0/mnt/floppy        Mount floppy
   mount-t vfat-o iocharset=utf8,umask=000/dev/hda2/mnt/hda2   Mount FAT32 partition
   mount-t ntfs-o nls=utf8,umask=000/dev/hda3/mnt/hda3          Mount NTFS Partitions
   linux-ntfs project:http://linux-ntfs.sourceforge.net/
   umount /mnt/hda3 unloading Download
   Note: Please check fdisk-l before mounting the device.

17.SU switch to another identity without exiting the login
Usage: SU-L user name (switch to root if user name is default)
Eg:su-l netseek (Switch to netseek This user, will prompt for password), plus-represents the switch to the user's environment variable.

Sudo leverages the permissions he can perform root execution

18.whoami,id,w,lastlog,users,groups
W View User login information
Who view current login
Last one months of user login
Lastlog check the last logon time for a particular user and format the output of the last logon log/var/log/lastlog
WhoAmI confirmed his identity.
ID prints out its UID as well as the GID. (UID: A unique identity for a user. GID: The user group identity is uniquely identified. Each user can have only one UID and GID.
Users
Groups the user group to which the user belongs;
Finger-l Netseek Root
Finger-s or Direct finger
Allows users to query some other user's information
Eg:finger//View the user information used by the users
Finger root//view root information


19. User-used commands and execution history commands
History displays commands that the user used to kill
!! Perform the most recent command

20.uname View Linux System Information
Parameters:-A All information-R version number-N Host name

21. Establish Soft Connection
ln [-SF] source target
ln Souce-file Hard-link
LN-SF Source-file Soft-link
s indicates a soft connection, f means that if there is a file with the same name, it is overwritten.
Note: Hard links cannot be created for directories, only files can create hard links.

22. View Table of Contents
Du-sh directory or file
Du-m du system The default output is in kilobytes, and the parameter-M is indicated in MB.
Cat/etc/fstab View Partition List
Fdisk-l
Df-h
Df-ah

23. View the resources that the Linux system occupies (top,free,uptime)
Top view background program, monitor system performance
TOP-D 2 new column every two seconds
top-d -2-p3690 View a PID
Top-b-N 2 >/tmp/top.txt The top information 2 times, and then outputs the results to/tmp/top.txt

Free-m View system memory usage

Uptime Displays the current system boot time (see how long, how many people log in, the past 1,5,15 minutes system load)


24. File Ratio software:
The CMP CMP (abbreviated by "compare") command is used to briefly indicate whether two files are different and use permissions for all users
The diff diff command is used for comparisons between two files and points to the difference between the two, and it uses permissions for all users

25. Remote operation and File transfer
SSH User@remote.machine
SCP User@remote.machine:/remote/path/local/path
Scp/local/path User@remote.machine:/remote/path

26. Compile the C + + file
Gcc
Gcc-v View GCC version
Gcc-o Test test.c 2>errfile Compile the test.c with an error message, redirect the error message to the Errfile

27.chattr +i filename Prohibit deletion, chattr-i filename cancellation prohibited
Lsattr View Hidden file properties


28. Automated implementation
At execution once
crontab Timer Cycle Execution procedure
Crontab Introduction
1 log in as root
2 # CRONTAB-E
3 Join a line
1 */12 * * */usr/sbin/ntpdate pool.ntp.org
Minutes (0-59)
Hours (0-23)
Date (1-31)
Month (1-12)
Week (0-6)//0 on behalf of Sunday


29. Shutdown and reboot:
Shutwond [-t-seconds] [-RKHNCFF] time [warning message]
-T seconds: Sets the delay time (in seconds) between warning and deletion of the two signals before switching to a different runlevel
-K issued a warning message, but not really to shutdown
-R shutdown reboot after this
-H shutdown This rear boot
-N does not go through init, by the shutdown command itself to boot work (not recommended)
When-F restarts, skips the fsck instruction and does not check the file system.
When-F restarts, force a fsck check.
-C cancels the action already being shutdown
Shutdown-h now shuts down immediately, in which time is 0,halt,poweroff or shut down, or direct init 0
Shutdown-h 20:30 system will be shut down in 8:30 tonight.
The Shutdown-h +10 system automatically shuts down after 10 minutes.
Shutdown-t3-r now reboots immediately, but in the warning and deletion processes this room,
Shutdown-k Now ' hey! Go away! Now ... ' A warning message was issued, but there was no real shutdown.


Reboot
Shutdown-r now is almost the same as reboot, not related to the proposed reboot execution as follows:
Shutdown-r +30 ' The system Wiil reboot '
Shutdown-r +10 ' hey!  Go away! ' The system reboots after 10 minutes.
#sync; Sync Sync Reboot Note: Sync writes data to the hard disk synchronously
The halt command is equivalent to shutdown-h now, which means that the machine shuts down immediately.
The reboot command is equivalent to Shutown-r now, which means that it immediately resets.

30. How to change the startup mode run level
Vi/etc/inittab
Change the 5 to 3, and it will turn into character mode after startup.
StartX or init 5 can enter the graphical interface.
RunLevel Display current run level

How to switch to single user mode
Use Telinit or init (in fact Telinit is just a synbol link to init)
Telinit 1 or Init s can, of course, Telinit S is ok.

How to make Ctrl+alt+del three key failure method
#vi/etc/inittab
Add a comment before ca::ctrlaltdel:/sbin/shutdonw-t3-r now #
Then execute #telinit q, the parameter q is to Telinit again/etc/inittab

31.TAB using the TAB key, when you do not know the full name of the file or command, please press the TAB key continuously.

32.clear Clear Screen

33.DMESG |more Display boot information (view hardware information at system startup)

34. Change the performance of the program to a good level
Nice set Priority Nice-n-5 VI & with ROOT to a nice value of-5, used to perform VI
Renice adjustment already exists priority

35. Module-related commands
LSMOD displays modules that have been loaded into the system
Depmod analysis of the dependencies of the loading system
Modinfo display information for kernel modules
Insmod Loading Module
Modprobe Automatic Process Loading module
Rmmod Delete Module

The 36.chkconfig--list displays the status of various services and makes it easy to manage the init script with Chkconfig.

The

37.linux of several decompression commands
   compress aaa  AAA file compression into AAA. Z
   compress-d aaa.z to compress aaa.z files to AAA
  
   gzip AAA compression Command
   gzip- D aaa.gz  Decompression Command
  
   bzip2-z filename compression, Ibid. plus-d parameter decompression
   bzcat filename.bz Viewing the contents of a compressed file
  
   tar czvf aaa.tar.gz AAA compresses catalog AAA into aaa.tar.gz
   tar-n ' 2007/03/ The '-ZCVF Home.tar.gz/home ' is back in/home than the new file in 2007/03/01.
   tar--exclude/home/cao-zxvf myfile.tar.gz/home/*/etc to back up/home,/etc, but do not/home/cao
   CD /tmp; TAR-CVF-/etc | TAR-XVF-After packing the/etc/, untie/tmp directly, without producing a file.
   tar zxvf aaa.tar.gz decompression command.
   tar jxvf aaa.tar.bz2 extract command
   tar zxvf aaa.tar.gz-c/var/www extract aaa.tar.gz to/var/www directory
   CPIO-COVB > [file|device] Backup
   Cpio-icduv < [file|device] restore

38. Network command
Ifconfig display or set up a network device, you can view the current IP, similar to the ipconfig in Windows
Service Network restart (/etc/rc.d/init.d/network restart) Reboot network card
Ifdown eth0 off the NIC
Ifup eth0 Open Network card
Route-n View routing Table
Route add-net 192.168.20.1 netmask 255.255.255.0 Dev eth0

Netstat View network connectivity
Netstat-i display of network card operation
Netstat-r View the list of routes for a host

Traceroute

Hostname Display host name
HOSTNAME-I Displays the IP of the current host name.

39. System Integration Management menu.
Setup System service Management command
NTSYSV Set up system services


40.FDISK/MBR Delete Grub

41. Database Startup
Start MySQL:
Service mysqld Start (/etc/rc.d/init.d/mysqld start)
Mysql-uroot-p Enter the password to operate the MySQL database.

Start Oracle
Su-oracle
$lsnrctl stop
$lsnrctl start
Sqlplus/nolog
Conn/as SYSDBA (connected)
Startup

42. Install Package
RPM Package Installation:
RPM-IVH xxx.rpm Installation RPM Package
Rpm-qa--last | Less shows installed packages based on the installation date
RPM-QA |grep mysql-i Query System install MySQL package (-I, ignore case)
RPM-E to remove installed packages
RPM-E mysql*--nodpes forced deletion of related packages
RPM--test Test Installation
Rpm-qi Query MySQL Suite description information
RPM-QPL xxx.rpm View the contents of the RPM package.
RPM-QC[D] Profile and specification file
RPM-UVH Upgrade Installation
Rpmbuild--BB Specs/xxx.spec will be xxx.spec compiled into an RPM package.
Rpmbuild--rebuild packagename.src.rpm again, src.rpm compiled into an RPM package.

Source code compilation installation (classic)
./configure Check System Information (./configure--help | More help information, you can see the relevant parameter settings)
Make clean erase files left before
Make compilation
Make install Installation
Note: The source package installation, generally first the file decompression, the installation process is generally above a few steps, specific description of the general opinion in the catalogue after the (install,reademe description.)

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.