ssh
to ssh into another box with a non-standard port
Zip
to zip all of a directory in linux
zip -r <file_name>.zip <dir_to_zip>
Tar
to tar the contents of a directory (creating the tar):
tar -cvf <file_name>.tar <dir_to_zip>
to add to an existing tar
tar -rvf <file_name>.tar <dir_to_zip>
to list the contents of a tar
to extract the file
to zip the file
To set the date time (to Jan 13 2006, 9:51am)
date -s "01/13/2006 09:51:00"
Secure Copy: scp
To copy a file from one box to another
scp -P 7272 <local file> user@host:<remote location>
Who's using the system, from where etc
w - show who is logged on and what they are doing
users - print the user names of users currently logged in to the current host
last - show listing of last logged in users
Links
To delete a symbolic link:
ie. Delete it as a regular file (make sure there is not / after it (if the link is a directory).
Finding text
The following command will find all css files containing "background.gif". Customise as required.
find . -name "*.css" -exec grep -H background.gif {} ";"
Deleting files
first to verify we're not deleting sensitive files.
The following command will use find to delete all found files
find . -name <file> -delete
Usually
will do on most *nix, but not on the Mac ;(
chkconfig
For checking and setting the run levels on a box
Global profiles
__Application Environment Setup Using /etc/profile.d/*_
When a user logs in, environment variables are set from various places. That includes /etc/profile (for all users).
Then all the files in the /etc/profile.d directory.
Then ~/.bash_profile, then ~/.bashrc.
/etc/profile.d/ is a good place to put your application specific setups. For example, I always use SSH for CVS (cf. RSH). So I use:
echo "export CVS_RSH=ssh" >> /etc/profile.d/cvs.sh
chmod +x /etc/profile.d/cvs.sh
Port forwarding (eg. access mysql through ssh)
Use the following command to allow connection from a local mysql client to connect to a remote mysql server on 3306 through ssh. (i.e. port 3306 is not open to outside world)
ssh -p 7272 -L 9906:localhost:3306 mpecher@marandcustomsolutions.com
then local client points to: port 9906, and ip 127.0.0.1