1, how to filter out the known current directory in the Oldboy of all the first level directory (hint: Do not include Oldboy directory under the directory of subdirectories and hidden directories, that is, only a primary directory).
^: With what begins, for example ^olboy to begin with Oldboy.
Ls:-f to identify different file types.
Method One:
- [[email protected] tmp]# find/oldboy-maxdepth 1-type d! -name "Oldboy"
Method Two:
- [Email protected] tmp]# Tree/oldboy-ld 1
Method Three:
- [[email protected] tmp]# ls./oldboy-lf|awk '/^d/'
Method Four:
- [[email protected] tmp]# ls./oldboy-lf|sed-n '/^d/p '
2. The access log of the Apache service is known to be logged by day in the server local directory/app/logs, which now requires only the last 7 days of access logs to be retained.
- [Email protected] tmp]# find/oldboy/test/-type f-name "access*.log"-mtime +7|xargs rm-f
- Or
- [Email protected] tmp]# find/oldboy/test/-type f-name "access*.log"-mtime +7-exec rm-f {} \;
3. Track changes at the end of a file
Tail-f file name
TAILF file name
Tail–f file name
4. The line number and content of the nginx.conf content of the printing configuration file
Cat-n file name
Grep-n "Match content" file name (line number displayed for matching results)
NL file Name
awk ' {print NR ' ' $} ' file name
Sed ' = ' file name
Less-n file name
VI file name, and then execute: set nu,:set noun to cancel the line number.
5, after loading the system, want to let network file Sharing service NFS, only in the 3 level on the boot from.
Chkconfig--level + sshd on
Chkconfig--list sshd
Requirements for chkconfig management scripts:
1, the execution/etc/init.d/oldboy restart format Normal service
2, the beginning of the script to add the following content:
#chkconfig: 35 56 24
#description: Oldboy Linux Test
Special attention:
/etc/init.d/oldboy start lets the program run now, Chkconfig is whether the management is powered on or not, and the two are not connected.
6, Linux system operating level is generally 0-6, please write down the meaning of each level.
0: Shutdown mode
1: Single-user mode
2: Multi-user mode with no NFS
3: Text mode (full multi-user mode)
4: Not used
5: Graphics mode
6: Restart mode
7, how to optimize the Linux system.
1, without root, add ordinary users, through sudo authorization management.
2, change the default remote connection SSH service port and prohibit the root user remote connection.
3. The server time is automatically updated periodically.
4, configure the Yum update source, download and install the RPM package from the domestic update source.
5. Turn off SELinux and iptables (work scenario if a WAN IP is typically turned on).
6, adjust the number of file descriptors, process and file opening will consume the file descriptor.
7, scheduled automatic cleaning/var/spool/clientmquene/directory garbage files, to prevent inodes consumption.
8. Streamline boot-up service (SSHD, Crond, Network, Rsyslog, Sysstat).
9, the Linux kernel parameter optimization/etc/sysctl.conf, the execution sysctl-p takes effect.
10, change the character set, support Chinese, suggested in English character set.
11. Lock critical system files.
Chattr +i/etc/passwd/etc/shadow/etc/group/etc/gshadow/etc/inittab
After processing, rename the chattr,lsattr.
12, clear/etc/issue, remove the system and kernel version before the screen display.
13, clear useless default system account or group.
8,/etc/directory for the Linux system default configuration files and services to start the directory of commands, 1, with tar packaging/etc The entire directory, 2, with tar/etc entire directory, but need to exclude/etc/services files; 3. Unzip the package in a TMP in the specified directory.
Tar zcvf [path]/basket [path] a bunch of apples
1:
Tar zcvf/tmp/etc.20161207.tar.gz/etc
-z:--gzip,--ungzip, call gzip to compress the archive file, and call when the-X is connected
-c:--create, create a new archive file
-v:--verbose, output related information during processing
-f:--file, packaging for ordinary files
Tar tf etc.20161207.tar.gz See what's in the package
-t:--list, view the contents list of the compressed package
-f:--file, for ordinary files
2:
Tar zcvf etc.20161207.tar.gz--exclude=/etc/services. etc
Write the file name that you want to exclude, and read the text to exclude it:
Tar zcvfx etc.20161207.tar.gz exclude file names./etc
--exclude: Exclude files or directories that you do not need to process
-x:--exclude-from, exclude files or directories that do not need to be processed in the form of a specified file list
3:
Tar XF etc.20161207.tar.gz (unzip to previous directory)
Tar XF etc.20161207.tar.gz-c/tmp (unzip to/tmp directory)
-x:--extract,--get, extracting files from an archive file
-c:--directory DIR, specifying directories for operation, such as extracting to the specified directory
-P: Preserve file properties
-P: Package with absolute path
Expand:
find/oldboy/-type F|xagrs tar zcvf oldboy.tar.gz
Tar zcvf oldboy.tar.gz ' Find/oldboy-type f '
9, echo "I am oldboy myqq is 49000448" >>oldboy.txt file filter out Oldboy and 49000448 strings, and in I am OLDBOY,MYQQ is 49000448 filter out.
I am Oldboy myqq is 49000448 filter:
Awk-f "" ' {print $ "" $NF} ' Oldboy.txt
Cut-d ""-f3,6 oldboy.txt
Cut-c 6-11,20-oldboy.txt
I am OLDBOY,MYQQ is 49000448 filter:
Sed ' s#,# #g ' oldboy.txt|cut-d ""-f3,6
Awk-f "[,]" ' {print $ ' "$6} ' Oldboy.txt
10. See how many lines a file has
Wc-l file name
Wc-l/etc/services
Cat-n/ETC/SERVICES|TAIL-1
11. Filter out the contents of a/etc/services file containing 3306 or 15,212 digits
Grep-e "3306|1521"/etc/services
Egrep "3306|1521"/etc/services
Linux command "second article"