搜尋文件裡面的關鍵字:
grep -rnw '/home/xx/xx/software/curl-7.56.1' -e 'curl_easy_perform'
unzip file to another folder:
tar xzf archive.tar.gz -C /destination
change User:
su - knight
check self:
whoami
show command content by page:
ls -al | more
show command content by page in second way:
ll | more
find executable file or command :
which ifconfig
system info:
dmesg | more
find specified file:
find /home -name(-size,-perm,-newer,-ctime)
search some word in file:
grep go install.log
search some word in command:
ls -al | grep word1
find path word:
echo $PATH
append word in exist file:
ls /bin >> file
modified or create file:
touch file1
remove directory forcely:
rm -rf folder1
add write permission for user:
chmod u+w john
Check disk space:
df
check folder space:
du -h
du -sh(total)
process check :
ps aux | more
process tree:
pstree
stop process:
ctrl + z
put process into background 1:
sleep 40 &
put process into background 2:
sleep 50 (ctrl + z)
bg
ps -f
put background/foreground for process:
bg/fg [number]
check bg jobs:
jobs
terminated process:
ps
kill [pid]
kill process :
ps
kill -9 [pid]
kill all process:
killall httpd
ps aux | grep httpd
process priority value:
nice -n -15 sleep 200 &
ps -l
use tree check folder:
tree /proc | more
write info to file directly:
echo "newmsg" > /home/file1
watch process dynamically:
top
tar file in normally:
tar -czvf file1.tar.gz file1
un-tar file in normally:
tar -xzvf file1.tar.gz
tar file with date value:
tar -czvf back-`date +%Y%m%d`.tar.gz file1
fix time to os with network world rule:
ntpdate watch.stdtime.gov.tw
fix time to bios hardware with network world rule:
hwclock -w(hwclock -r)
show rpm installed-softwares:
rpm -qa
install gcc(conveniently way):
yum install gcc
install gcc(conveniently way with direct):
yum -y install ncurses-devel
make specified-size file for testing:
dd if=/dev/zero of=file1 bs=1M count=3
if:use /dev/zero's output zero string
of:file name
bs:every block's size
count:how many block
count file's info:
wc file1.log
11 22 33 file1.log
11 is row count
22 is character count
33 is byte count
ssh connect another linux pc:
ssh root@10.1.1.1
cross another linux to copy(local to remote):
scp file1 root@10.1.1.1:/home/john
cross another linux to copy(remote to local):
scp root@10.1.1.1:/home/john/file1 .(. is now folder)
serial number generator (use in shell script's loop tasks) :
seq 2 17 ,seq (-w) 1 2 13
sort file context by line :
sort file1(english file) , sort -g file2(number file)
remove repeat-line file by line:
uniq doc1
sort & uniq file:
sort f1 | uniq
get column value in records:
raw file-
rex,14,333
gary,53,999
yard,64,022
cut -d',' -f 2 file1
split file:
dd if=/dev/zero of=file1 bs=2M count=3
split -b 1m file1
join file:
cat xaa xab xac > file1
check 2 files are different or not:
diff file1 file2
network basic command:
ping -c 3 tw.yahoo.com
traceroute tw.yahoo.com
hostname
netstat –tnl (-n:port ,-t:tcp ,-u:udp, -l:info ,-p:pid and name)
use simple word cmd to replace long word cmd(alias):
alias dv='du -sh /var'
remove alias:
unalias dv
add alias to fixed setting file for exist alias in reboot:
cat ~/.bashrc
echo variable to show:
echo "$PATH"
echo three line word:
echo -e "line1\nline2\nline3"
set variable and get variable:
set: what=”now”
get: echo $ what
detect previous command success or not:
ls
echo $?
Result: if success ,it is 0; if fail ,it is over 0.
File test(1 is false,0 is true):
-d(folder) ,-e(exist?),-s(size is 0?),-r(read?),-w(write?)
-x(execute?),-L(link?),-n(length over 0?),-z(string is empty?)
A.test –d file1
echo $?
B.w1=”123”
w2=”ggh”
test $w1 == $w2
echo $?
Two value comparison(1 is false,0 is true):
v1=13
v2=16
test $v1 –eq(equal) $v2
-ne(different)
-ge(great or euqlal)
-gt(great)
-le(least or equal)
-lt(least)
echo $?
Check .bashrc content:
cd /root
ls –a .bas*
make a shell script and running it:
vi file1
n1=$1
n2=$2
test $n1 -gt $n2
chmod u+x file1
./file1 11 15
echo $?
If judgement:
if test $v1 –gt $v2
then
echo “bigger”
else
echo “smaller”
fi
For judgement:
for n in ‘seq 1 10’
do
echo $n
done
check Loopback network equipment :
ifconfig eth0
start/stop network card:
ifconfig eth0 up/down
configure network’s ip and netmask:
ifconfig eth0 192.168.1.2 netmask 255.255.255.0
show equipment info:
ip address show , ip link show
equipment Statistics info:
ip –s link show eth0
assign ip to specific equipment:
ip address add 10.2.3.1/24 brd + dev eth0
check assign ip to specific equipment:
ip address show dev eth0
delete ip to specific equipment:
ip address del 10.2.3.1/24 dev eth0
change equipment attribute:
ip link set eth0 up/down
find a specific ps:
ps aux | grep httpd
check system service start or not:
apt-get install chkconfig
chkconfig –list apache2 (--list:boot runlevel show)
system service start or stop:
chkconfig –level 35 httpd on/off
start/stop standalone service:
a.service [httpd/apache2] start
b./etc/init.d/[httpd/apache2] start
add new crontab task:
vi /etc/crontab (add in last line)
0 23 * * 4 root /usr/sbin/backup.sh
service crond restart
add alias to web url path:
echo “Alias /data /opt/docs” >> /etc/httpd/conf/httpd.conf
service httpd restart
限制無法存取其他目錄:
vi /etc/vsftpd/vsftpd.conf
最後加入tcp_wrappers=YES
加入禁錮名單:
echo "edw" >> /etc/vsftpd/user_list
look ip for dns:
dig [@143.25.53.12] www.kimo.com.tw
(@ip is DNS Server)
Look ip for server name:
host www.kimo.om
host www.kimo.com 41.12.124.6
host –t ns you.tube
start DNS server(after installing bind software):
service named start
(or /etc/init.d/named start)
start DNS server(after booting),better to close firewall and SELinux:
chkconfig –level 35 named on
DNS內部查詢:
dig @127.0.0.1 www.websome.com
DNS 外部查詢:
dig @192.168.1.13 www.websome.com
正常DNS 外部查詢:
dig www.websome.com
grep -rnw '/home/xx/xx/software/curl-7.56.1' -e 'curl_easy_perform'
unzip file to another folder:
tar xzf archive.tar.gz -C /destination
change User:
su - knight
check self:
whoami
show command content by page:
ls -al | more
show command content by page in second way:
ll | more
find executable file or command :
which ifconfig
system info:
dmesg | more
find specified file:
find /home -name(-size,-perm,-newer,-ctime)
search some word in file:
grep go install.log
search some word in command:
ls -al | grep word1
find path word:
echo $PATH
append word in exist file:
ls /bin >> file
modified or create file:
touch file1
remove directory forcely:
rm -rf folder1
add write permission for user:
chmod u+w john
Check disk space:
df
check folder space:
du -h
du -sh(total)
process check :
ps aux | more
process tree:
pstree
stop process:
ctrl + z
put process into background 1:
sleep 40 &
put process into background 2:
sleep 50 (ctrl + z)
bg
ps -f
put background/foreground for process:
bg/fg [number]
check bg jobs:
jobs
terminated process:
ps
kill [pid]
kill process :
ps
kill -9 [pid]
kill all process:
killall httpd
ps aux | grep httpd
process priority value:
nice -n -15 sleep 200 &
ps -l
use tree check folder:
tree /proc | more
write info to file directly:
echo "newmsg" > /home/file1
watch process dynamically:
top
tar file in normally:
tar -czvf file1.tar.gz file1
un-tar file in normally:
tar -xzvf file1.tar.gz
tar file with date value:
tar -czvf back-`date +%Y%m%d`.tar.gz file1
fix time to os with network world rule:
ntpdate watch.stdtime.gov.tw
fix time to bios hardware with network world rule:
hwclock -w(hwclock -r)
show rpm installed-softwares:
rpm -qa
install gcc(conveniently way):
yum install gcc
install gcc(conveniently way with direct):
yum -y install ncurses-devel
make specified-size file for testing:
dd if=/dev/zero of=file1 bs=1M count=3
if:use /dev/zero's output zero string
of:file name
bs:every block's size
count:how many block
count file's info:
wc file1.log
11 22 33 file1.log
11 is row count
22 is character count
33 is byte count
ssh connect another linux pc:
ssh root@10.1.1.1
cross another linux to copy(local to remote):
scp file1 root@10.1.1.1:/home/john
cross another linux to copy(remote to local):
scp root@10.1.1.1:/home/john/file1 .(. is now folder)
serial number generator (use in shell script's loop tasks) :
seq 2 17 ,seq (-w) 1 2 13
sort file context by line :
sort file1(english file) , sort -g file2(number file)
remove repeat-line file by line:
uniq doc1
sort & uniq file:
sort f1 | uniq
get column value in records:
raw file-
rex,14,333
gary,53,999
yard,64,022
cut -d',' -f 2 file1
split file:
dd if=/dev/zero of=file1 bs=2M count=3
split -b 1m file1
join file:
cat xaa xab xac > file1
check 2 files are different or not:
diff file1 file2
network basic command:
ping -c 3 tw.yahoo.com
traceroute tw.yahoo.com
hostname
netstat –tnl (-n:port ,-t:tcp ,-u:udp, -l:info ,-p:pid and name)
use simple word cmd to replace long word cmd(alias):
alias dv='du -sh /var'
remove alias:
unalias dv
add alias to fixed setting file for exist alias in reboot:
cat ~/.bashrc
echo variable to show:
echo "$PATH"
echo three line word:
echo -e "line1\nline2\nline3"
set variable and get variable:
set: what=”now”
get: echo $ what
detect previous command success or not:
ls
echo $?
Result: if success ,it is 0; if fail ,it is over 0.
File test(1 is false,0 is true):
-d(folder) ,-e(exist?),-s(size is 0?),-r(read?),-w(write?)
-x(execute?),-L(link?),-n(length over 0?),-z(string is empty?)
A.test –d file1
echo $?
B.w1=”123”
w2=”ggh”
test $w1 == $w2
echo $?
Two value comparison(1 is false,0 is true):
v1=13
v2=16
test $v1 –eq(equal) $v2
-ne(different)
-ge(great or euqlal)
-gt(great)
-le(least or equal)
-lt(least)
echo $?
Check .bashrc content:
cd /root
ls –a .bas*
make a shell script and running it:
vi file1
n1=$1
n2=$2
test $n1 -gt $n2
chmod u+x file1
./file1 11 15
echo $?
If judgement:
if test $v1 –gt $v2
then
echo “bigger”
else
echo “smaller”
fi
For judgement:
for n in ‘seq 1 10’
do
echo $n
done
check Loopback network equipment :
ifconfig eth0
start/stop network card:
ifconfig eth0 up/down
configure network’s ip and netmask:
ifconfig eth0 192.168.1.2 netmask 255.255.255.0
show equipment info:
ip address show , ip link show
equipment Statistics info:
ip –s link show eth0
assign ip to specific equipment:
ip address add 10.2.3.1/24 brd + dev eth0
check assign ip to specific equipment:
ip address show dev eth0
delete ip to specific equipment:
ip address del 10.2.3.1/24 dev eth0
change equipment attribute:
ip link set eth0 up/down
find a specific ps:
ps aux | grep httpd
check system service start or not:
apt-get install chkconfig
chkconfig –list apache2 (--list:boot runlevel show)
system service start or stop:
chkconfig –level 35 httpd on/off
start/stop standalone service:
a.service [httpd/apache2] start
b./etc/init.d/[httpd/apache2] start
add new crontab task:
vi /etc/crontab (add in last line)
0 23 * * 4 root /usr/sbin/backup.sh
service crond restart
add alias to web url path:
echo “Alias /data /opt/docs” >> /etc/httpd/conf/httpd.conf
service httpd restart
限制無法存取其他目錄:
vi /etc/vsftpd/vsftpd.conf
最後加入tcp_wrappers=YES
加入禁錮名單:
echo "edw" >> /etc/vsftpd/user_list
look ip for dns:
dig [@143.25.53.12] www.kimo.com.tw
(@ip is DNS Server)
Look ip for server name:
host www.kimo.om
host www.kimo.com 41.12.124.6
host –t ns you.tube
start DNS server(after installing bind software):
service named start
(or /etc/init.d/named start)
start DNS server(after booting),better to close firewall and SELinux:
chkconfig –level 35 named on
DNS內部查詢:
dig @127.0.0.1 www.websome.com
DNS 外部查詢:
dig @192.168.1.13 www.websome.com
正常DNS 外部查詢:
dig www.websome.com
沒有留言:
張貼留言