Linux Basic Command One __linux

Source: Internet
Author: User

1. Compile and link to deliver executable file sample

Gcc-c-i/usr/local/include/http_test.cpp-o HTTP_TEST.O

Gcc-l/usr/local/lib-lboost_locale http_test.o-o Test

2. Find

The contents of the current directory contain a field file and display the file directory:

Find. -name "*.h"-exec grep-in-h "string" {} \;

To find the file name in the current directory that contains a string.

$ find. -print | Grep-in string//note: String do not use wildcard characters

find MD5 for all files in a specified directory

$ find. -exec md5sum {} + | awk ' {print $ ' \ t ' $} ' | Sort > Md5.txt

Grep-ein ' a|b ' Console.log

3. Decompression

Link: http://www.cnblogs.com/eoiioe/archive/2008/09/20/1294681.html

with path compression properties:

$tar-CZVF/***/web-inf/lib.bak.tar.gz/***/web-inf/lib--absolute-names

extract to specific path properties:

' Tar-xvzf #{propel_home}/. /idm-service-#{idm_version}.tar.gz-c#{propel_home}/.. /idm-service/'


4. Batch Replacement

\//Escape

Sed-i "s/\/home\/artogrid\/workspace\/dev/. \/.. /g "' Grep\/home\/artogrid\/workspace\/dev-rl./*/*.sh '

Sed-i "s/tcp:\/\/192.168.1.102/tcp:\/\/172.16.8.40/g" ' Greptcp:\/\/192.168.1.102-rl./*/*.xml '

Sed-i "s/idb_cswap_account/idb_account/g" ' grep idb_cswap_account-rl./sumscope/cswap/*/bin/*servercfg.xml '


XML Special Character substitution:

Replace <companyid>1 to <companyid>9000

Sed-i "S~<companyid>1~<companyid>9000~g" grep "<companyid>1"-RL./sumscope/cswap/cmanageserver/ Bin/cmanageservercfg.xml '


grep l only lists file names

5. Set the generated core dump file size Unlimited

Ulimit-c Unlimited


6. CP-RF a b/still has coverage hint, can view alias

[Root@localhost workspace]# Alias
Alias cp= ' Cp-i '
........

If a CP alias exists, it can be temporarily canceled

[Root@localhost workspace]# unalias CP

Then execute CP-RF a B, without prompting.


Shell script:

[-N ' alias-p | grep ' ^alias cp= '] && unalias CP
CP-RF Folder1 Folder2

Alias cp= ' Cp-i '


7. Find the process run path

Method One:

A. PS Lookup process Number

B. View/proc/pid_no

eg

[Root@localhost/]# ps-elf | Grep-in "Qpid"
244:1 S root 3569 1 0 0-182221 Ep_pol Oct26? 00:37:58./qpidd--max-connections=2000--auth=no--tcp-nodelay-d--log-source Yes--log-thread Yes--log-to-file. Log
261:0 S root 20236 20192 0 0-25829-18:12 pts/6 00:00:00 grep-in qpid
[Root@localhost/]# ll/proc/3569
Total dosage 0
......
-R--------1 root root 0 December 13:43 environ
lrwxrwxrwx 1 root 0 December 13:43 exe->/home/artogrid/workspace/deploy/qpid/qpidd

......

Method Two: Top command + C


8. Modify user groups and Permissions

[Root@idbcentos65 bondserver]# LL

-rwxr-xr-x. 1 root 143 Dec 16:54 modify_cfg.sh
[Root@idbcentos65 bondserver]# chown Centos:centos modify_cfg.sh
-rwxr-xr-x. 1 CentOS CentOS 143 Dec 16:54 modify_cfg.sh
[Root@idbcentos65 bondserver]# chmod g+w modify_cfg.sh//or chmod 777 File
-rwxrwxr-x. 1 CentOS CentOS 143 Dec 16:54 modify_cfg.sh

U: Current user of the directory or file
G: Current group of directories or files
O: Users or groups other than the current user or group of directories or files
A: All Users and Groups

Modify directory and subdirectory user groups

root@ubuntu:/workspace# chown-r Stack:stack devstack/


to add sudo permissions to a user

#echo "User all= (All) nopasswd:all" >>/etc/sudoers

To create a multilevel catalog :

Mkdir-p a/b/c

9. View service

#service--status-all


Yum

A. View installed applications

#yum List installed

B. Delete

#yum Remove MySQL

c. Find Installable Packages

#yum Search JDK

Refer to:http://blog.chinaunix.net/uid-346158-id-2131252.html

containers used by the D.yum server

Yum Repolist All

E. Delete information about all the containers that have been downloaded

#yum Clean All


11. Date Time modification and synchronization

Modified : Date

# date-s "2008-08-08 12:00:00"

When you have finished modifying, remember to enter: Clock-w

Writes the system time to the CMOS

sync : #ntpdate 202.120.2.101


12. Proxy Settings

/etc/profile Join

Export http_proxy=http://***.com:8080

Export https_proxy=http://***.com:8080


13. View HTTP response

Curl-v "HTTP Address"


14.Vim line number permanently in effect

/ETC/VIMRC or ~/.VIMRC Add "set number"

15. Security

SELinux enhanced security, the closure of the method is:
1. Permanent and effective
Modify the Selinux= "" in the/etc/selinux/config file as disabled and reboot.
2. Immediate entry into force
Setenforce 0
The firewall shutdown method is:
1. Permanent entry into force
Open: Chkconfig iptables on
Close: Chkconfig iptables off
View Status: Sestatus

2. Immediate entry into force, restart after failure
Open: Service iptables start
OFF: Service iptables stop

16. Hard disk space View

[tiaxia@c9t21622 ftp]$ df-k
FileSystem 1k-blocks Used Available use% mounted on
/dev/sda3 999320 481052 465840 51%/
.......

Ps:df-h (human-readable)
[tiaxia@c9t21622 ftp]$ du-h
4.0K./pub
4.0K./propel
12K.
[tiaxia@c9t21622 ftp]$ Du-ck
4./pub
4./propel
12.
Total

View the size of the directory
[root@c9t21622 var]# Du-sh *
4.0K Account
100M Cache
1.1M Chef
40K crash
4.0K CVS

[root@c9t21622 var] #du-sh
1.3G

17. Switch to root

#sudo-S

#sudo su

ssh to Linux server via publish key

Linux client generates private/publish key command # Ssh-keygen

Copy pub key content to service-side/.ssh/authorized_keys file (. ssh) (Authorized_keys 644)

(Authorized_keys can add more than one client public key)

SSH Server-ip

server-side Public private key POS:/etc/ssh/ssh_host* , delete, reboot [/etc/init.d/sshd restart] to regenerate the service-side public key.

However, other clients may be affected, and the server information stored by other clients is ~/.ssh/known_hosts


19. View System Information

Release version

$ uname-a

$ cat/etc/redhat-release

$cat/etc/issue

$cat/proc/version

CPU Information

$cat/proc/cpuinfo

20. View Domain name

Hostname
Cat/etc/sysconfig/network
Cat/etc/hosts
Modify Linux Host Name
Hostname ceshi.com

21. View the port corresponding process

$ LSOF-PNL +m-i4 | grep 5671

22.shell into the current script path

CD ' DirName $ '
echo "pwd:" ' pwd '

LN

To create a soft connection for TX in the Docker directory

Ln-s/opt/mount1/tx Docker

lrwxrwxrwx 1 Tiaxia LDAP 06:06 tx->/opt/mount1/tx

24. View CPU Kernel Count

Cat/proc/cpuinfo |grep "cores" |uniq

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.