특정 디렉토리에서 불특정 파일의 추가 텍스트의 로그 보기
inotifywait . -m -e CLOSE_WRITE --format '%f' | while IFS= read -r f; do cat "$f" | sed -e 's/[^\]\\n/\n/g'; done
svn mv `find ./ -maxdepth 1 -type f | grep "pub*"` publisher
diff -r -q /dir/ | grep -v pyc | grep -v svn > rsync_filelist
두 디렉토리를 비교해서 파일이 다른 것들을 찾는것
ESC = CTRL + {
명령어 전부 지우기 : ESC + { + Backspace, CTRL + U
DEL키 : CTRL + D
^S stops scrolling (Xoff)
^Q resume scrolling (Xon)
EXIT FREEZING SSH : Enter + ~ + .
R옵션 : 재귀검색, 아래의 커맨드는 정말 자주 사용된다.
grep -R 'New MySQL' ./
You can select only those lines containing matches that form whole words using the -w option. In this example, search for word ‘getMyData()’ only in ~/projects/ dirctory:
$ grep -w -R 'getMyData()' ~/projects/
grep : Search for two or more words
Use the egrep command as follows:
$ egrep -w -R 'word1|word2' ~/projects/
@@ 먼저 ssh 또는 telnet 을 이용하여 서버에 접속한다음 screen 세션을 생성한다.
$ screen -S [세션명]
@@ 그리고 공동작업할 사람역시 해당 서버에 접속한다음 같은 세션명으로 다음과 같이 참여한다
$ screen -x [세션명]
@@ 이제 두 사람은 같은 화면을 보면서 동시 작업이 가능. 종료 : ctl-A D
Connect Apple Bluetooth keyboard
$ hidd --connect 60:FB:42:0C:D3:48 $ sudo hidd --connect 60:FB:42:0C:D3:48 $ echo 0 > /sys/module/hid_apple/parameters/fnmode
umask u=rwx,g=rwx,o=rx
이후 umask -S로 확인할수 있다.
(완전히 정확하지는 않습니다)
files=$(find ./ -name "*.java*" -type f); for file in $files; do echo -n "${file}: "; file -i $file | awk -F" " '{ print $3 }' | cut -c9-20; done | grep -v iso-8859-1; files=$(find ./ -name "*.java*" -type f); for file in $files; do echo -n "${file}: "; file -i $file | awk -F" " '{ print $3 }' | cut -c9-20; done | grep -v iso-8859-1 | awk -F":" '{print $1}';
@@ ISO-8859-1 to UTF-8 변환
files=$(find ./ -name "*.java*" -type f); for file in $files; do encoding=`file -i $file | awk -F" " '{ print $3 }' | cut -c9-20`; if [ 'iso-8859-1' = $encoding ]; then iconv -f EUC-KR -t UTF-8 ${file} > ${file}.tmp && mv -f ${file}.tmp ${file}; else echo "${file} was break"; fi; done;
echo "userpassword" | sshfs -p 5522 user@192.168.0.150:/home/user ~/SERVER -o uid=1001,gid=1002,password_stdin
files=$(find . -type f -name "*.java"); for file in $files; do iconv -c -f euckr -t utf8 $file > $file.tmp && mv -f $file.tmp $file; done
OIFS="$IFS"; IFS=$'\n'; for file in `find . -type f -name "*.smi"` do iconv -c -f utf-8 -t euc-kr "$file" > $file.tmp && mv -f $file.tmp $file; done; IFS="$OIFS"
우분투 쓰는 사람들에게는 정말 유용하게 사용됨
$ sudo apt-get install wmctrl $ wmctrl -lxp
네트워크 패킷 검사
——————————————————————————–
Display Captured Packets in ASCII using tcpdump -A
——————————————————————————–
$ tcpdump -A -i eth0
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on eth0, link-type EN10MB (Ethernet), capture size 96 bytes
14:34:50.913995 IP valh4.lell.net.ssh > yy.domain.innetbcp.net.11006: P 1457239478:1457239594(116) ack 1561461262 win 63652
E…..@.@..]..i…9…*.V…]…P….h….E…>{..U=…g.
……G..7\+KA….A…L.
14:34:51.423640 IP valh4.lell.net.ssh > yy.domain.innetbcp.net.11006: P 116:232(116) ack 1 win 63652
E…..@.@..\..i…9…*.V..*]…P….h….7……X..!….Im.S.g.u:*..O&….^#Ba…
E..(R.@.|…..9…i.*…]…V..*P..OWp……..
——————————————————————————–
Display Captured Packets in HEX and ASCII using tcpdump -XX
——————————————————————————–
$tcpdump -XX -i eth0
18:52:54.859697 IP zz.domain.innetbcp.net.63897 > valh4.lell.net.ssh: . ack 232 win 16511
0x0000: 0050 569c 35a3 0019 bb1c 0c00 0800 4500 .PV.5………E.
0x0010: 0028 042a 4000 7906 c89c 10b5 aaf6 0f9a .(.*@.y………
0x0020: 69c4 f999 0016 57db 6e08 c712 ea2e 5010 i…..W.n…..P.
0x0030: 407f c976 0000 0000 0000 0000 @..v……..
18:52:54.877713 IP 10.0.0.0 > all-systems.mcast.net: igmp query v3 [max resp time 1s]
0x0000: 0050 569c 35a3 0000 0000 0000 0800 4600 .PV.5………F.
0x0010: 0024 0000 0000 0102 3ad3 0a00 0000 e000 .$……:…….
0x0020: 0001 9404 0000 1101 ebfe 0000 0000 0300 …………….
0x0030: 0000 0000 0000 0000 0000 0000 …………
——————————————————————————–
Capture the packets and write into a file using tcpdump -w
——————————————————————————–
$ tcpdump -w 08232010.pcap -i eth0
tcpdump: listening on eth0, link-type EN10MB (Ethernet), capture size 96 bytes
32 packets captured
32 packets received by filter
0 packets dropped by kernel
——————————————————————————–
Read packets longer than N bytes
——————————————————————————–
tcpdump -w g_1024.pcap greater 1024
——————————————————————————–
Read packets lesser than N bytes
——————————————————————————–
$ tcpdump -w l_1024.pcap less 1024
——————————————————————————–
Receive only the packets of a specific protocol type
——————————————————————————–
$ tcpdump -i eth0 arp
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on eth0, link-type EN10MB (Ethernet), capture size 96 bytes
19:41:52.809642 arp who-has valh5.lell.net tell valh9.lell.net
19:41:52.863689 arp who-has 11.154.12.1 tell valh6.lell.net
19:41:53.024769 arp who-has 11.154.12.1 tell valh7.lell.net
——————————————————————————–
Capture packets for particular destination IP and Port
——————————————————————————–
$ tcpdump -w xpackets.pcap -i eth0 dst 10.181.140.216 and port 22
——————————————————————————–
Capture TCP communication packets between two hosts
——————————————————————————–
$tcpdump -w comm.pcap -i eth0 dst 16.181.170.246 and port 22
——————————————————————————–
15. tcpdump Filter Packets – Capture all the packets other than arp and rarp
——————————————————————————–
$ tcpdump -i eth0 not arp and not rarp
20:33:15.479278 IP resolver.lell.net.domain > valh4.lell.net.64639: 26929 1/0/0 (73)
20:33:15.479890 IP valh4.lell.net.16053 > resolver.lell.net.domain: 56556+ PTR? 255.107.154.15.in-addr.arpa. (45)
20:33:15.480197 IP valh4.lell.net.ssh > zz.domain.innetbcp.net.63897: P 540:1504(964) ack 1 win 96
20:33:15.487118 IP zz.domain.innetbcp.net.63897 > valh4.lell.net.ssh: . ack 540 win 16486
20:33:15.668599 IP 10.0.0.0 > all-systems.mcast.net: igmp query v3 [max resp time 1s]
——————————————————————————–
기타예제
——————————————————————————–
// 라우팅되는 패킷도 검사할수 있다.
sudo tcpdump -n -i wlan0 dst 172.20.10.1
~/.profile 파일에 설정하면 리눅스에서 최초 로그인시에 설정된다. 따라서 이 파일을 편집후에 터미널을 켜도 환경변수는 반응하지 않는다. 재 로그인 필요 또는 <ALT>+<CTRL>+F1 등을 누르고 로그인 테스트!
또는 su 명령어로 –login 옵션을 가지고 들어가면 된다.
~/.bashrc 파일은 매 로그인시 적용되는 파일이다.
~/.bash_profile is only sourced by bash when started in interactive login mode. That is typically only when you login at the console (Ctrl+Alt+F1..F6), or connecting via ssh.
When you log in graphically, ~/.profile will be specifically sourced by the script that launches gnome-session (or whichever desktop environment you’re using). So ~/.bash_profile is not sourced at all when you log in graphically.
When you open a terminal, the terminal starts bash in (non-login) interactive mode, which means it will source ~/.bashrc.
The right place for you to put these environment variables is in ~/.profile, and the effect should be apparent next time you log in.
Sourcing ~/.bash_profile from ~/.bashrc is the wrong solution. It’s supposed to be the other way around; ~/.bash_profile should source ~/.bashrc.
See DotFiles for a more thorough explanation, including some history of why it is like it is.
(On a side note, when installing openjdk via apt, symlinks should be set up by the package, so that you don’t really need to set JAVA_HOME or change PATH)
tar cvf vim.tar.gz .vim tar --append --file vim.tar .vimrc
ps aux | grep synergys # 프로세스 번호를 알아낸뒤 lsof -p 2416 # 다음처럼 자원 목록을 살펴본다.
exec 3>&1 : 기존에는 /proc/nnnn/fd/3 proc가 없다. 이상황에서 3번 파일디스크립터를 연다.
grep Comment examples.dektop 2>/dev/null 이러한 식으로 해당 출력이 “표준출력”인지 “표준에러”인지 알아낸다.
exec 3<> aaa : 3번 FD를 aaa와 연결한다.
$ echo “djfkldsajkf” >&3
$ cat aaa
djfkldsajkf
$ echo “djfkldsajkf” >&3
$ cat aaa
djfkldsajkf
djfkldsajkf
$ echo “djfkldsajkf” >&3
$ cat aaa
djfkldsajkf
djfkldsajkf
djfkldsajkf
exec 3>&- : 3번 파일디스크립터를 닫는다.
$ php -i | grep -i mysqli Configure Command => './configure' '--build=i686-redhat-linux-gnu' '--host=i686-redhat-linux-gnu' '--target=i386-redhat-linux-gnu' '--program-prefix=' '--prefix=/usr' '--exec-prefix=/usr' '--bindir=/usr/bin' '--sbindir=/usr/sbin' '--sysconfdir=/etc' '--datadir=/usr/share' '--includedir=/usr/include' '--libdir=/usr/lib' '--libexecdir=/usr/libexec' '--localstatedir=/var' '--sharedstatedir=/usr/com' '--mandir=/usr/share/man' '--infodir=/usr/share/info' '--cache-file=../config.cache' '--with-libdir=lib' '--with-config-file-path=/etc' '--with-config-file-scan-dir=/etc/php.d' '--disable-debug' '--with-pic' '--disable-rpath' '--without-pear' '--with-bz2' '--with-curl' '--with-exec-dir=/usr/bin' '--with-freetype-dir=/usr' '--with-png-dir=/usr' '--enable-gd-native-ttf' '--without-gdbm' '--with-gettext' '--with-gmp' '--with-iconv' '--with-jpeg-dir=/usr' '--with-openssl' '--with-png' '--with-pspell' '--with-expat-dir=/usr' '--with-pcre-regex=/usr' '--with-zlib' '--with-layout=GNU' '--enable-exif' '--enable-ftp' '--enable-magic-quotes' '--enable-sockets' '--enable-sysvsem' '--enable-sysvshm' '--enable-sysvmsg' '--enable-track-vars' '--enable-trans-sid' '--enable-yp' '--enable-wddx' '--with-kerberos' '--enable-ucd-snmp-hack' '--with-unixODBC=shared,/usr' '--enable-memory-limit' '--enable-shmop' '--enable-calendar' '--enable-dbx' '--enable-dio' '--with-mime-magic=/usr/share/file/magic.mime' '--without-sqlite' '--with-libxml-dir=/usr' '--with-xml' '--with-system-tzdata' '--enable-force-cgi-redirect' '--enable-pcntl' '--with-imap=shared' '--with-imap-ssl' '--enable-mbstring=shared' '--enable-mbstr-enc-trans' '--enable-mbregex' '--with-ncurses=shared' '--with-gd=shared' '--enable-bcmath=shared' '--enable-dba=shared' '--with-db4=/usr' '--with-xmlrpc=shared' '--with-ldap=shared' '--with-ldap-sasl' '--with-mysql=shared,/usr' '--with-mysqli=shared,/usr/lib/mysql/mysql_config' '--enable-dom=shared' '--with-dom-xslt=/usr' '--with-dom-exslt=/usr' '--with-pgsql=shared' '--with-snmp=shared,/usr' '--enable-soap=shared' '--with-xsl=shared,/usr' '--enable-xmlreader=shared' '--enable-xmlwriter=shared' '--enable-fastcgi' '--enable-pdo=shared' '--with-pdo-odbc=shared,unixODBC,/usr' '--with-pdo-mysql=shared,/usr/lib/mysql/mysql_config' '--with-pdo-pgsql=shared,/usr' '--with-pdo-sqlite=shared,/usr' '--enable-dbase=shared' /etc/php.d/mysqli.ini, mysqli MysqlI Support => enabled MYSQLI_SOCKET => /var/lib/mysql/mysql.sock mysqli.default_host => no value => no value mysqli.default_port => 3306 => 3306 mysqli.default_pw => no value => no value mysqli.default_socket => no value => no value mysqli.default_user => no value => no value mysqli.max_links => Unlimited => Unlimited mysqli.reconnect => Off => Off
#!/bin/sh findpid=$1 known_windows=$(xwininfo -root -children|sed -e 's/^ *//'|grep -E "^0x"|awk '{ print $1 }') for id in ${known_windows} do xp=$(xprop -id $id _NET_WM_PID) if test $? -eq 0; then pid=$(xprop -id $id _NET_WM_PID|cut -d'=' -f2|tr -d ' ') if test "x${pid}" = x${findpid} then echo "Windows Id: $id" fi fi done mycroft:~ $ ./find_windows.sh 1919 Windows Id: 0x1800748 Windows Id: 0x181b221 Windows Id: 0x1803ad5 Windows Id: 0x181f681 Windows Id: 0x181f658 Windows Id: 0x180006d Windows Id: 0x1800003 Windows Id: 0x1800001 Windows Id: 0x180001e
du -h --max-depth=1
ls -R | grep ":$" | sed -e 's/:$//' -e 's/[^-][^\/]*\//--/g' -e 's/^/ /' -e 's/-/|/'
$ 7z e azdesign_ME3_jellybean_custompack.7z.001
find *.xml | xargs tar cvf ANDROID__2014_03_21_XML.tar;
sudo arping -I eth0 130.68.49.35 sudo arp-scan -I eth0 -l sudo arp-scan -I eth0 -l | sort
sudo usermod -a -G sudo <username>
readlink -f /usr/bin/java
user1@webterror:~$ ps -o pid,comm,user,thcount 7198 PID COMMAND USER THCNT 7198 chrome user1 8
$ uuidgen -r # random based UUID/GUID $ uuidgen -t # time based UUID/GUID
좋은정보 감사합니다.
앞으로 잘 활용하게 될 것 같아서 정보좀 가져가겠습니다.
공유 감사드려요!