Linux one liners
Diff two directories
|
1 |
diff -rq /dir1 /dir2 |
Set suid
File: File executes as the user that owns the file, not the user that ran the file
|
1 |
chmod u+s |
Set sgid
File: File executes as the group that owns the file
Dir: Files newly created in the directory have their group owner set to match the group owner of the directory
1
chmod u+s
1
chmod g+s
|
1 |
chmod u+s |
|
1 |
chmod g+s |
Set Sticky bit
File: no effect
Dir: User with write on the directory can only remove files that they own, they can not remove files owned by other users
|
1 |
chmod o+t |
Tar + gzip on the fly in linux
|
1 |
# tar cvf - somedir | gzip -c > somedir.tar.gz |
List all ips on ifconfig except loopback
|
1 |
ifconfig | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1}' | uniq |
List sockets to Listen on in httpd.conf
|
1 |
cat /path/to/httpd.conf | grep -i listen | grep -v "#" | cut -d: -f1 | awk '{print $2}' | sort -n | uniq |
Find ips set to listen on httpd.conf
|
1 |
cat /path/to/httpd.conf | grep -i listen | grep -v "#" | cut -d: -f1 | awk '{print $2}' | sort -n | uniq |
Find sockets set to listen in all files under a directory
|
1 |
grep -Ri listen /path/to/vhosts | grep -v "#" | awk '{print $2}' | sort -n |uniq |
Find ips set to listen in all files under a directory
|
1 |
grep -Ri listen /path/to/vhosts | grep -v "#" | awk '{print $2}' | sort -n | cut -d: -f1 |uniq |
find all ips set to listen in all httpd.conf files
1
locate httpd.conf | xargs grep -i listen | grep -v "#" | awk '{print $2}' | sort -n | cut -d: -f1 | uniq
Scripts
|
1 |
locate httpd.conf | xargs grep -i listen | grep -v "#" | awk '{print $2}' | sort -n | cut -d: -f1 | uniq |
some useful linux/unix scripts
linux dedupe problems?
Here’s a nice dedupe script i found:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
#!/bin/bash # Filename: dedupe.sh # source: http://ithacafreesoftware.org/forum/viewtopic.php?f=7&t=326 # this file takes two text files as input # sorts them and outputs lines from # file 2 that do not exist in file 1 # into a new file called [file 1].clean if [ -f "$1" ] && [ -f "$2" ] then # sort both files sort -u $1 > $1.tmp; sort -u $2 > $2.tmp; comm -13 $1.tmp $2.tmp > $2.clean; else echo "Usage: dedupe.sh file1 file2"; echo "where file1 is the 'master' file"; echo "and file2 is the file possibly containing duplicates"; fi |