Thursday, 6 December 2012

Linux Commands

Limit resource a user can access

edit file /etc/security/limits.conf

//show limits
ulimit -a

See differences between two folders

diff -rq folder1 folder2

Find file in mac or Linux

find ./ -name platform_check.php

Open image

open test.png
open test.jpg

curl

//curl to redirect content to file
curl  --output leo.jpg https://checkout.whahaha-content.com/images/unionpay.png

created nested directories

The -p flag will create nested directories if directories do not exist. If exist, do nothing.

//mkdir: leo: No such file or directory
mkdir leo/test

//this works
mkdir -p leo/test

sed command

replace all occurences of a pattern

//ie flag will replace in place and that file will be modified
sed  -ie 's/unix/linux/g' my.txt

//all leo in my.txt will be replaced by developer. Also will make a backup file called my.txt.bak
sed -i.bak "s/leo/developer/g" my.txt

find which process is using a port number in mac

lsof -nP -iTCP -sTCP:LISTEN | grep port-number

No comments:

Post a Comment