36 the third week of work

1, define an alias for all the users are in force, for example: lftps = 'lftp 172.168.0.1/pub'

vim /etc/bashrc
alias lftps=‘lftp 172.168.0.1/pub’
. /etc/bashrc

2, the display / etc / passwd file not to / bin / bash line end

grep -v "/bin/bash$" /etc/passwd

3, find / etc line / passwd contains two or three digits

grep -o "[[:digit:]]{2,3}" /etc/passwd
or
grep -o "\b[0-9]{2,3}\b" /etc/passwd

4, the display / proc / meminfo file, all the rows in the upper or lower case at the beginning of S; implemented in three ways.

grep -i ^s /proc/meminfo
grep ^[Ss] /proc/meminfo
egrep "^S|^s" /proc/meminfo

5, an absolute path echo out, take-off path name using egrep

echo /etc/rc.d/init.d/functions |egrep [^/]+$

6, to find the ip address of ifconfig. The results showed that only requires IP address

ifconfig ens33 |grep -o "[0-9.]{7,}" |head -n1
ifconfig ens33 |grep -o "[[:digit:]]{1,3}[.][[:digit:]]{1,3}[.][[:digit:]]{1,3}[.][[:digit:]]{1,3}" |head -n1
ifconfig ens33 |grep -o "inet [0-9.]+" |cut -d" " -f2

7, vim customized automatic indentation four characters
vim / etc / vim / vimrc last to join
the SET the TabStop = 4
the SET shiftwidth = 4

8, write a script, automatically add three users, and calculate the sum of these three users uid and
#! / Bin / bash
useradd user1 user2 && && useradd useradd USER3
user_id1 = $ (the above mentioned id -u user1)
user_id2 = $ (the above mentioned id user2 -u)
user_id3 = $ (-u ID USER3)
echo "$ [user_id1 $ + $ + $ user_id2 user_id3]"

9, find and use the strength of common usage demo

According to name queries, such as queries have been the beginning of a:

find /etc -name a*

Time changes the file only queries based on, for example, query the last two days changed files:

find /etc -mtime -2

Query files larger than 512KB of:

find /etc -size +512k

Query file permissions, such as the highest authority 777:

find /etc -perm 777

The owner is natasha find the file, and copy the files found to / root / findfiles

find / -user natasha type -f -exec cp -p {} /root/findfiles/ \;

Guess you like

Origin blog.51cto.com/14387464/2407734