-
Notifications
You must be signed in to change notification settings - Fork 0
gnu linux files
arvin karimi edited this page Apr 6, 2018
·
3 revisions
- Srwxrwxrwx r = 4 w = 2 x = 1 S = sticky bit, define directory or file
chown -R www-data:www-data /var/www
chmod -R 755 test/ # uga+rwx, u=wg
chmod -R 6711 test/ # setgid and setuid bitmkdir -p 1/2/3 # create: p stands for parents
rm -rf 1 #remove(dir and file): r stands for recursive, f stands for force
mv 1 p/o/ # move file and directory`
mv 1 p # rename file directory
cp -r -v 1/ o/ # copy
touch touched.txt # change file access time , if file does not exist will make it.- options :
- -h : print sizes in human readable format (e.g., 1K 234M 2G)
- -H : likewise, but use powers of 1000 not 1024
- -i : list inodes
df -h- options :
- -h : print sizes in human readable format (e.g., 1K 234M 2G)
- -H : likewise, but use powers of 1000 not 1024
- -c : total
- -s : summerize
- --max-depth
- --time
du -h -c /home/arvin/- options :
- -v : verbose
- -x : extract
- -f : file
- -z : gzip, -j : bzip2
- -c : create, -r : append, --delete : delete from archive
tar -cvfj test.tar.bz /home 1.txt 2.txt
tar -xvf test.tar.bz
tar -rf test.tar.bz 3.txt- options :
- -L : list not matched files
- -l : list matched files
- -c : count
- -e : regex
- -i : ingore case
- -v : invert match
- -n : show matched line number
- -r : recursive
- -w : word
- -x : line
grep -r -n -c -e "[^gnu].*x" .
- options:
- -type: (d: directory, f: file)
- -name (-iname : ignore case)
- -o or, -not (!)
- -perm
- /a=x
- /u=r
- 0566
- sgid (2564)
- -exec
- -user, -group
- -mtime (modified files by day), -atime (accessed files by day)
- -cmin (changed by minutes), -amin, -mmin
- -size
find ./test -name 'abc*' ! -name '*.php'
find ./test -iname "*.Php"
find ./test -not -name "*.php"
find -name '*.php' -o -name '*.txt'
find . -type f ! -perm 0777
find /home/bob/dir -type f -name *.log -size +10M -exec rm -f {} \;- locate does not check whether files found in database still exist. locate can never report files created after the most recent update of the relevant database.
- options:
- -n : limit lines
- -c : count
- -i : ignore case ```bash locate -i text.txt
* -S : review locate db * -d : change db path (-d [dbpath])
- update db : updatedb files: /etc/updatedb.conf /var/lib/mlocate/mlocate.db
To create a private mlocate database as an user other than root, run
updatedb -l 0 -o db_file -U source_directory- copy and convert files 1- dd options:
2- iconv
3- sed
- options:
- -n : number all output lines
- -A : equivalent to -vET
- -E : display $ at end of each line, -e:-vE
- -T : display TAB characters as ^I, -t: -vT
- -v : use ^ and M- notation, except for LFD and TAB
cat test test1
cat -n test1- more (file perusal filter for crt viewing), less (opposite of more)
more file1
tail -F /var/etc/nginx/access.logs | more2- sort (sort lines of text files)
* options:
* -n : numeric-sort
* -r : reverse
* -k : sort by column number
* -t : field separator
* -u : unique
* -h : human-numeric-sort
bash sort file1 file2 sort file1 sort -r file1 sort -t "," -nk3 file1.csv sort -u file1 ls -alh | sort > sorted.text
- options:
- -l : lines
- -w : words
- -m : chars
- -c : bytes
wc -l file1- options :
- -F : follows and retry to connect ( -f --retry)
tail -F -n 20 /var/log/nginx/access.loghead -n 20 /var/log/nginx/access.log- options
- -l : customize line (ex -l1200)
- -b : file size (ex: -b 500M)
- -n : Generate n chunks output files (ex -n5)
- -e : Prevent Zero Size Split output files
in below example
ngxis prefix of generated file
split /var/log/nginx/access.log ngxmerge splited files
cat Split_IS0_a* > Windows_Server.iso-
options
- -1 (field of first file)
- -2 (field of second file)
join -1 2 -2 1 wine.txt reviews.txt
sorted
join -1 2 -2 1 <(sort -k 2 wine.txt) <(sort reviews.txt)
- -t (specify a field separator for joining)
join -1 2 -2 3 -t , names.csv transactions.csv
paste file1 file2