Linux Command
User & Password
We have below users and their password:
root
ryan (sudoer)
grace
Login as ryan:check password expiration
1
chage -1 ryan # number 1
change password
1
passwd # for user self
login as
root
1
su - root
change password for
grace
1
passwd grace
login as
grace
1
su grace
become
root
1
sudo su - root
set password never expire, must done by root
1
2
3
4
5
6
7
8chage ryan
Minimum password age:0
Maximum password age:99999
Last password change: enter
Expiration warning: enter
Password Inactive: enter
Account expiration date: -1
File & Directory
- check directory size
1
du -sh <path>
- monitor log
1
tail -100f <file>
- monitor log and catch specific content
1
tail -100f <file> | grep "<content>"
- change file modified time
1
touch -d 20170101 <file>
- delete files that mtime > 71209-16:32 will delete files before 1201-16:32. Completed data for 7 days from 1202 to 1208
1
find $dir -type f -mtime +7 -name '*.txt' -execdir rm -- '{}' \;
- copy and move
1
2[cp / scp / mv] <originFile> <targetFile> / <targetDir>
scp ryan@IP:~/test.txt ~ - create file
1
touch <file>
- remove
1
2rm <file>
rm -r <dir> # delete all the files and dirs in this dir (include) - count number of files
1
fileNumber=`ls -1R <dir> | wc -l`
- zip and unzip
1
2gzip <file>
gunzip *.gz - permission
1
chmod 755 <file>
Run Program
- nohup-1- runApp will be kept running at the background
1
2cd ~/myApp
nohup ./runApp.sh &
-2- the output like echo will be put into~/myApp/nohup.out
- job process id
1
jobPid="$(ps -ef | grep ksh | grep runApp.sh | awk '{print $2}')"
- kill job
1
kill -9 <jobPid>
- pass parameter
1
runApp.sh xyz # so in runApp.sh, $1="xyz"
Operation
- if else
1
2
3
4
5if [""=""]; then
action
else
action
fi
Compile / Build Java Program
1 | releasePath=~/myApp |
Others
- press to continue
1
2echo "Press to continue.."
read q