Username, Password, User ID, Group ID, User ID Info, Home directory, Command/shell
Example:
tom:x:1001:1001:Tom Cruise:/home/zac:/bin/bash
Group name, Password, Group ID, Group List
Example:
sudo:x:27:Lucy,Tom
sudo adduser new_username
# Or
sudo useradd new_username
sudo userdel username
# Then you may want to delete the home directory for the deleted user account :
sudo rm -r /home/username
To modify the username of a user:
usermod -l new_username old_username
To change the password for a user:
sudo passwd username
To change the shell for a user:
sudo chsh username
To change the details for a user (for example real name):
sudo chfn username
To add a user to the sudo group:
adduser username sudo
# Or
usermod -aG sudo username
:set nu
:set number
:0 //jumps to the first line
:$ //jumps to the last line
G //jumps to the first line$
1G //jumps to the last line
0 //gets you to the beginning of the line
$ //gets you to the end of the line
/ //search type n to find next, N find previous
u //Undo last change
U //Undo all changes to line
a //Append after cursor
A //Append after line
x //Delete character to the right of cursor
X //Delete character to the left of cursor
D //Delete to the end of the line
dd //Delete current line
:d //Delete current line
5dd or d5d //Delete 5 lines
i //Insert before cursor
I //Insert before line
o //Open a new line after current line
O //Open a new line before current line
r //Replace one character
R //Replace many characters
nyy //Type 12yy to copy the 12 lines, without n, default is 1.
p //Type p to insert the copied line after the current line.
ggdG //clear content of a file
gg //go to the 1st line
dG //delete lines under the cursor
adduser moodlelocal
vim /etc/passwd
# moodlelocal:x:1002:1002:,,,:/aemg/cloudclassroom/moodle/local:/usr/sbin/nologin
getfacl local
setfacl -R -m u:moodlelocal:rwX local
service vsftpd restart
# add user to another group
usermod -a -G dubbo moodlelocal
groups moodlelocal
cd /etc/httpd/conf
vim httpd.conf
# open Include conf.d/*.conf
cd /etc/httpd/conf.d
cp ss.conf iosc.conf
# Change following lines accordingly
# DocumentRoot /var/www/iosc
# ServerName iosc.aemg.com.au
ln -s /aemg/cloudservice/iosc /var/www/ios
# Addtionally, you may need to remove #RewriteBase /
vim /aemg/cloudservice/iosc/.htaccess
service httpd restart
type exit to quit from ssh
ssh [email protected]
ssh [email protected] -p2222
/etc/vsftpd.userlist
netstat -ant | grep 21
# in local shell, copy remote server's file
scp [email protected]:/home/zac/my.tar /Users/devmac/Desktop
scp /Users/zach/Desktop/polyv_node/package.json [email protected]:/home/dubbo/zach
# Copy ssh pub key to server
$ ssh-keygen -t rsa -b 2048
$ ssh-copy-id id@server
$ ls ~/.ssh/authorized_keys
mysql> use mysql;
mysql> SELECT user, host FROM user WHERE user = 'root';
mysql> grant select,insert,update,delete,create,drop on mydb.mytable to [email protected] identified by 'mypassword';
# grant all on [database name].[table name] to [user name]@[host name];
mysql> grant all privileges on *.* to [email protected] identified by 'mypassword';
mysql> grant all privileges on *.* to lzpddd@'%' identified by 'mypassword';
mysql> grant all privileges on *.* to 'root'@'%' identified by '###' with grant option;
mysql> flush privileges;
mysql> show databases;
mysql> mysql -u username -pmypassword -h 192.168.1.88 -P 3306 -D dbname
mysql> select user,host from mysql.user;
mysql> SELECT table_schema AS "Database", ROUND(SUM(data_length + index_length) / 1024 / 1024 / 1024, 2) AS "Size (GB)" FROM information_schema.TABLES GROUP BY table_schema;
mysql> mysqldump -u root -p### classicmodels > d:\db\classicmodels.sql
mysql> mysql -u root -p### classicmodels_backup < d:\db\classicmodels.sql
# chown mysql:adm /var/log/mysql/query.log
# chown mysql:adm /var/log/mysql
# chown root:syslog /var/log
# chown root:root /var
# chmod 0640 /var/log/mysql/query.log
# chmod 0750 /var/log/mysql
# chmod 0775 /var/log
# chmod 0755 /var
mysql> SHOW VARIABLES LIKE 'general_log%';
mysql> SET GLOBAL general_log = 'ON';
mysql> SET GLOBAL general_log_file = '/var/log/mysql/query.log';
# : > query.log #清空文件
# 配置文件-/etc/mysql/mysql.cnf
Run this command to just remove the JDK
sudo rm -rf /Library/Java/JavaVirtualMachines/jdk.jdk
Run these commands if you want to remove plugins
sudo rm -rf /Library/PreferencePanes/JavaControlPanel.prefPane
sudo rm -rf /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin
sudo rm -rf /Library/LaunchAgents/com.oracle.java.Java-Updater.plist
sudo rm -rf /Library/PrivilegedHelperTools/com.oracle.java.JavaUpdateHelper
sudo rm -rf /Library/LaunchDaemons/com.oracle.java.Helper-Tool.plist
sudo rm -rf /Library/Preferences/com.oracle.java.Helper-Tool.plist
This searches every object in the current directory hierarchy (.) that is a file (-type f) and then runs the command grep "example" for every file that satisfies the conditions. The files that match are printed on the screen (-print). The curly braces ({}) are a placeholder for the find match results. The {} are enclosed in single quotes (') to avoid handing grep a malformed file name. The -exec command is terminated with a semicolon (;), which should be escaped (;) to avoid interpretation by the shell.
# find files which contain key word, both have same effect
find . -type f -print | xargs grep "example"
find . -type f -exec grep "example" '{}' \; -print
# move all the local files to /opt/shell
find . -type f -exec mv {} /opt/shell \;
find . -type f | xargs -I '{}' mv {} /opt/shell
# Find and delete
find . -maxdepth 1 -name "*.bak" -delete
find -name 'logjd_*' | xargs rm -f
List all the java process, remove the current running grep process, the difference is standard syntax
ps -ef | grep java | grep -v grep
ps aux | grep node | grep -v grep
du -sh ./dist
ls -lh
df -lh
tail -f nohup.out
curl -i -H "Content-type: application/json" -H "X-AUTH-TOKEN:eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJtYXJzLnpoYW5nQGFlbWcuY29tLmF1IiwibGFuZyI6bnVsbCwiaWF0IjoxNTIyMTE3NjQxOTE0LCJqdGkiOiJtYXJzLnpoYW5nQGFlbWcuY29tLmF1In0.KYdKLjYnhWhVkk3Mf_QTJ5qtP3h9CMNbfgq4Qz6U3h0" -X POST -d '{"from":"0","to":"2","Gtasks":"true"}' http://localhost:8080/maven-web-demo/rest/tSTaskController/
选择最后 20 行,将其保存到 results.txt,但是只在屏幕上显示这 20 行中的第一行
tee 命令有一个非常有用的选项(-a),它允许您将数据追加到已有文件。
sed -n -e 5,8p -e 10p file
tail -n20 /var/log/mail/info |tee results.txt |head -n1
cat mylog_2018-04-27.txt -n | head -n 50 | tail -n 10
cat -n 打印行号
cat > filename 创建文件
cat pushcourier.log.2015-04-20|grep DIANHUA|wc -l
cat api.log | grep -inE --color=auto "优速速递|doMessage"
cat api.log|grep sendAndroidUnicast | wc
cat catalina.out | grep -C 5 method_saveavatar //前后五行
cat /etc/passwd | sort -t':' -k 7 -u //第七个域进行排序,然后去重:
cat logsn_2015-11-22.txt | grep saveCookie |awk -F'>' '{print $4}' | sort -u | wc -l
cat logsn_2015-11-22.txt | grep insertOrder | grep true | awk -F'>' '{print $3}' | sort | uniq -c |wc
cat search.log | grep poll | awk -F[\|] '{print $5"#"$6}'| sort | uniq -c | sort -n
cat api.log.150706 | grep '|poll|' | awk -F[\|] '{print $5","$6}' | sort | uniq -c | wc -l
cat search.log.150708 | grep '|query|' | awk -F[\|] '{print $5","$6}' | sort | uniq -c | wc -l
cat search.log.150708 | awk -F[\|] '{print $5","$6}' | sort | uniq -c | wc -l
1、找出该进程内最耗费CPU的线程,可以使用ps -Lfp pid或者ps -mp pid -o THREAD, tid, time或者top -Hp pid
2、printf "%x\n" 24730
3、jstack 24715 | grep 609a
ssh [email protected] -p2222
kill -s 9 1772
nohup node loadjd.js &
iostat -xm 2
free -m
netstat -lnap | grep 1134
iptables
iptables -t mangle -F
vi /etc/sysctl.conf
半连接攻击 syn flood
编辑 net.ipv4.tcp_syncookies = 1
这个给你启用了,在高并发的时候,部分连接会丢失,确保端口可以打开
mv macloadjd.js loadjd.js
forever stop app.js
forever start -e ./log/jdforever.error.log -a loadjd.js
iptables -I INPUT -s 42.62.37.0/24 -j DROP
curl -H 'X-Real-IP:192.168.0.1' -H 'X-Forwarded-For:192.168.0.2' -v 'http://192.168.248.201:9101/query?type=yuantong&postid=888888888'
export PATH=/opt/kuaidi100/node/node-v0.10.28-linux-x64/bin:$PATH
wget
grep 'jin' a.txt |grep 'qi'
grep -n "A\|B" *
ubuntu :sudo service mongod start
var jq = document.createElement('script');
jq.src = "https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js";
document.getElementsByTagName('head')[0].appendChild(jq);
// ... give time for script to load, then type (or see below for non wait option)
jQuery.noConflict();
adb shell
pm list packages -f
pm uninstall -k --user 0 com.baidu.input_huawei
ionic serve --address 10.0.0.51
blkid
sudo mount -o remount,rw /partition/identifier /mount/point
mkfs -t ext4 /dev/sdc1
mkdir -p /media/seagate
mount /dev/sdc1 /media/seagate
vi /etc/fstab
/dev/sdc1 /media/seagate ext4 defaults 0 2
mount -a
[zac@AEMG-CS ~]$ uname -a
[zac@AEMG-CS ~]$ uname -r
[zac@AEMG-CS ~]$ cat /proc/version
[zac@AEMG-CS ~]$ cat /etc/lsb-release
[zac@AEMG-CS ~]$ cat /etc/issue
[zac@AEMG-CS ~]$ lsb_release -a
[zac@AEMG-CS ~]$ top
[zac@AEMG-CS ~]$ uptime
[zac@AEMG-CS ~]$ free -h
[zac@AEMG-CS ~]$ cat /proc/meminfo
[zac@AEMG-CS ~]$ cat /proc/2995/status
[zac@AEMG-CS ~]$ cat /proc/2995/stat
[zac@AEMG-CS ~]$ ps aux --sort -rss
[zac@AEMG-CS ~]$ vmstat -s
sysstat:
iostat(1), sar(1), mpstat(1)