Posts

Showing posts with the label linux command

Using "wget" to check web server status

Please use this # wget -O - | grep -O : indicate output filename - : send content to std output ref www.terminalinflection.com/using-wget-to-test-web-server-connectivity/

Using hexdump to check special chars on files

When you suspect on some word that will hide something inside. And I already have compare file. First thing I will try >>> diff file1 file2 Then I know more which word, so I >>> grep file1 And I'm not sure what wrong with it , I will >>> grep file1 | hexdump -C got thing like 00000000  48 65 6c 6c 6f 20 48 6f  77 20 61 72 65 20 79 6f  |Hello How are yo| 00000010  75 20 74 6f 64 61 79 0a  0a                       |u today..| 00000019 But I think it useless, I decide to >>> grep file1 | hexdump -c got this 0000000   H   e   l   l   o       H   o   w       a   r   e       y   o 0000010   u       t   o   d   a   y  \n  \n                           ...

Mount hfs+ system ( especially mac drive )

Hi pow 1. Let's do >>> sudo apt-get install hfsprogs 2. Unmount that drive, then >>> sudo fsck.hfsplus /dev/sdb2 or sudo fsck.hfsplus -f /dev/sdb2 Above are for checking its health 3. Do mount! >>> sudo mount -t hfsplus -o force,rw /dev/sdb2 /media/ ,just that my friend! :)

Short Note about linux redirection

While i run test script (it's usually output to stderr if it's error). Many times an error is too big to display in one display. So i am thinking about linux redirect >> ./runtests 2>&1 | head Summary    M>N,  M discriptor to filename N    M>&N, M discriptor to another N discriptor

Grep option from Jua

Today tasks, when we want to grep something we use >> ls -l | grep Jua tell me, if i need everything except >> ls -l | grep -v    # I think it's come from exclude by help said invert match!!! ### Thank Jua :) Anyway, we can use some simple regular expression by >> ls -l | grep -e [regex] such as >> ls -l | grep -e ^B

About DPKG

ref  http://www.cyberciti.biz/howto/question/linux/dpkg-cheat-sheet.php ref  http://linuxprograms.wordpress.com/2010/05/14/dpkg-tutorial/ Very thank for Owners of 2 links above. The first column corresponds to the status of a package. How to interpret this status. Status of every package is represented by  three characters xxx Let’s explore each of the character signify. First character : The possible value for the first character. The first character signifies the desired state, like we (or some user) is marking the package for installation u: Unknown (an unknown state) i: Install (marked for installation) r: Remove (marked for removal) p: Purge (marked for purging) h: Hold Second Character : The second character signifies the current state, whether it is installed or not. The possible values are n: Not- The package is not installed i: Inst – The package is successfully installed c: Cfg-files – Configuration files are present u: Unpacked- The pac...

Bash Shortcuts

These content are from SKORKS ( http://www.skorks.com/2009/09/bash-shortcuts-for-maximum-productivity/ ), Thanks Alan Skorkin Command Editing Shortcuts Ctrl + a  – go to the start of the command line Ctrl + e  – go to the end of the command line Ctrl + k  – delete from cursor to the end of the command line Ctrl + u  – delete from cursor to the start of the command line Ctrl + w  – delete from cursor to start of word (i.e. delete backwards one word) Ctrl + y  – paste word or text that was cut using one of the deletion shortcuts (such as the one above) after the cursor Ctrl + xx  – move between start of command line and current cursor position (and back again) Alt + b  – move backward one word (or go to start of word the cursor is currently on) Alt + f  – move forward one word (or go to end of word the cursor is currently on) Alt + d  – delete to end of word starting at cursor (whole word if cursor is at the beginning of wor...

How to multiple rename with bash

Sorry the wiseman, I can't remember that guy who post this knowledge. ( he 's alway great ).  In your command line ( bash ) do $ for file_name in *. ; do mv $file_name ${file_name/ / }; done; for example $ for f in *.sql; do mv $f ${f/.sql/.dump}; done; Then every sql files in your current folder will be .dump files hahaha :)

My command line shortcuts

My command line shortcuts ------------------------------------ alt-d : delete a word, starting at the current cursor position. ctrl-a : move to beginning of line. ctrl-e : move to end of line. ctrl-k : delete all characters in the line, starting the cursor position. ctrl-x : delete all characters in the line before current cursor position. ctrl-u : delete current line. ctrl-w : delete last word of current cursor.

How to start something after boot/reboot

In someway we can deal with rc.local. This is quite a good way to do this that I got this technique from head infrastructure of my company ( the japman ) Edit /etc/rc.local, Add it before sleep command.

whowatch - console, interactive, process and users monitoring tool

For checking current activities of users on system sudo apt-get install whowatch

du and df usage

Show summary for each * du -sckh * Show all with human-readable, total df -ah --total

Something about su and sudo

su - run a shell with substitute user and group IDs (  http://linux.die.net/man/1/su  ) sudo, sudoedit - execute a command as another user (  http://linux.die.net/man/8/sudo  ) The sudo allows a permitted user to execute a command as a superuser or another user as specified in the sudoers file ( which we can edit by visudo command ). The su is frequently use with -c ( --command ). But we put those 2 together like below example $ sudo su -c "whoami;echo $HOME"   # may be you'll get root and current user's home $ sudo -u hudson sh -c "whoami;pwd;whoami" ref http://linux.die.net

Linux networking #1

$ sudo route $ sudo vi /etc/resolveconf/resolv.conf.d/base $ sudo /etc/init.d/resolvconf restart

SMB usage

$ smbtree   # show list of smb share $ smbclient -L $ smbclient \\\\host\\sharename

SSH with X11 forward

$ ssh -Y # forward X11 Enables trusted X11 forwarding.  Trusted X11 forwardings are not subjected to the X11 SECURITY extension controls. You can use -X but -Y must be better.

Create user for linux

$ useradd -m -p -s

Check partition type in linux

Just     $ df -T -h or     $ sudo fdisk -l ref :  http://www.cyberciti.biz/faq/linux-how-to-determine-find-out-file-system-type/

Create file with size for testing purpose

Have you guys even need to have some file with size and its content not neccessary! Here it is $  dd if=/dev/zero of=output.dat bs=1024 count=10240 now we get file -- name : output.dat -- size :1024 * 10240 -> ~10mb Thanks for ( http://linuxcommando.blogspot.com/2008/02/create-file-of-given-size.html )