Posts

Showing posts with the label linux admin

Cool bash command for summary bot visited

I just found quite cool bash combination cat test.log | awk -F\" '{print $6}' | sort | uniq -c | sort -n from this  http://www.blogtips.org/web-crawlers-love-the-good-but-kill-the-bad-and-the-ugly/ I try it with nginx log, the result is look good. :)

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/

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! :)

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...

Combination of commands to remove something

I wanna move some folder name pip-* , every folders to /mnt/tmp3. But monitor server does not allow me to do it. So i keep do it 100 folders each time. I end up with this below $ ls -tr | grep pip- | head -n100 | xargs -i{} sudo mv {} /mnt/tmp3

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 :)

Change hostname on ShogunVPS

Edit /etc/hostname --------------------------    replace on line with myservice.mycompany.com Edit /etc/host -------------------    add new line after 127.0.0.1   localhost    with    127.0.0.1   myservice.mycompany.com **NOTE** this method passed test on ShogunVPS

How to disable ubuntu auto update

How to disable ubuntu auto update ----------------------------------------------- ( because it create some spike on incoming network , almost above 2m on zabbix ) 1. Be root 2. edit file /etc/apt/apt.conf.d/10periodic 3. change          APT::Periodic::Update-Package-Lists "1";     to           A PT::Periodic::Update-Package-Lists "0"; thank to Japman ( proteus lead infrastructure )

Clean swap

If i want to clean swap space     $ sudo swapoff -a     $ sudo swapon -a  ref  http://superuser.com/questions/271829/clean-up-swap-memory

SVN adduser

I can both add new svn user or change svn password     htpasswd -m username but if is not valid . I can     htpasswd -c

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

BASH scripting TIP #1

In bash script file $? - store exit value of last command that was executed $* - store all args "$@" - store all args, individually with qoute "$1", "$2" $1 - first arg $2 - second arg $n - nth arg

Some trouble shooting that I just found and use :) #1

KVM machine in my office turn on with its kvm's instances. But some of them don't got an IP, even network interface card. So here is what i have found. $ sudo ifconfig eth0 up   # to bring up eth0 $ sudo dhclient -r   # release ip  $ sudo dhclient   # obtain ip ref cyberbiz website