« Newer Snippets
Older Snippets »
9 total  XML / RSS feed 

unix linux commands

tar -xzf *.tar.gz

#adding user for service
/usr/sbin/adduser -r user_name
#and just user
/usr/sbin/adduser -p qwe123 user_name

iptables
iptables -A INPUT -p tcp -m tcp --dport 80 -j ACCEPT
iptables -A OUTPUT -p tcp -m tcp --dport 80 -j ACCEPT
/sbin/service iptables restart

symbolic link

ln -s /home/user/railsapps/app1/public /home/user/public_html/app1

Remote FTP transfer with ncftpput

When you can't use SCP…

ncftpput -u username -p password ftpperso.free.fr -R -m /local/path /remote/path

opening in a textmate project all files that match a pattern

This will pass all matched filenames to textmate, generating a project with all files flatly in the drawer (no dirs)

egrep -lr pattern * | grep -v .svn | xargs mate

Getting a less verbose list of installed gems

Wanna know what gems you have installed without looking at all the descriptions?

gem list | egrep -v "^( |$)"


Here's a (trimmed) sample output:

$ gem list | egrep -v "^ |^$"
*** LOCAL GEMS ***
actionmailer (1.2.1, 1.2.0, 1.1.5)
actionpack (1.12.1, 1.12.0, 1.11.2)
actionwebservice (1.1.2, 1.1.1, 1.1.0, 1.0.0)
activerecord (1.14.2, 1.14.1, 1.14.0, 1.13.2)
activesupport (1.3.1, 1.3.0, 1.2.5)
BlueCloth (1.0.0)
capistrano (1.1.0)
diff-lcs (1.1.2)

Mount and install OS X packages from the command line

If you need to install a .pkg application wrapped in a .dmg file from the command line (say, if you only have SSH access to the machine) there are a few command line utilities that will let you do this. For instance, let's say you're trying to install DarwinPorts on a remote OS X box.

cd ~/Desktop

curl -O http://darwinports.opendarwin.org/downloads/DarwinPorts-1.2-10.4.dmg

hdiutil attach DarwinPorts-1.2-10.4.dmg

cd /Volumes/DarwinPorts-1.2/

sudo installer -pkg DarwinPorts-1.2.pkg -target "/"

hditutil detach /Volumes/DarwinPorts-1.2/


In a nutshell, this 1) goes to your Desktop folder 2) grabs DarwinPorts from the opendarwin site 3) mounts the dmg 4) goes to the newly mounted DarwinPorts volume 5) installs the package, targeted to the root, as the root user 6) ejects the mounted disc image.

get rid of mac's ._ meta files on unix command line

When a mac accesses storage not formatted in it's own HFS format, it stores it's additional metadata about the file in another file named the same but starting with "._" It can be annoying and when you're accessing a remote volume that's source control managed with subversion, they show up your status information. This bash shell script will get remove of all ._metadata files residing below the current working directory.

#!/bin/sh
for i in `find . -regex '.*\._.*'`; do rm $i; echo "removing $i"; done


If you save that as "/home/$USER/bin/cleanup" and do a "chmod 777 /home/$USER/bin/cleanup" it will be available next time you open a terminal by just typing "cleanup".

Reverse DNS from command line

Quick and easy way to look up a domain name given an IP address.

dig -x 17.254.3.183


List 10 largest files/directories within the current directory

From the textdrive fora

du -sk * | sort -n | tail -10


This will list the top 10 largest files and/or directories below the directory where you run this command.
« Newer Snippets
Older Snippets »
9 total  XML / RSS feed