[ start | index | login ]
start > Linux > Commands

Commands

Created by mpecher. Last edited by mpecher, one year and 129 days ago. Viewed 1,179 times. #27
[diff] [history] [edit] [rdf]
labels
attachments

bash programming intro

>>http://www.faqs.org/docs/Linux-HOWTO/Bash-Prog-Intro-HOWTO.html

ssh

to ssh into another box with a non-standard port
ssh <server> -p <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
tar -v --list --file=/
to extract the file
tar -xvf

to zip the file

gzip <file_name>.tar

Date/Time see Date,Time,TimeZones for full info.

To set the date time (to Jan 13 2006, 9:51am) Note AMERICAN DATE FORMAT
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:
rm link_name
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.
find . -name .DS_Store

The following command will use find to delete all found files (.svn files)

find . -name *.svn -exec rm -rf {} ;

Usually

rm -rf <fileOrDir>
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

lstail

This bit of bash will do an ls 100 times
for i in $(seq 1 100); do ls -alp; sleep 0.25; done
no comments | post comment

Menu:
Java & J2EE
Development
Books

Help:
Help FAQ
Formatting


< September 2010 >
SunMonTueWedThuFriSat
1234
567891011
12131415161718
19202122232425
2627282930


Logged in Users: (0)
… and 14 Guests.



Disclaimer: Views and opinions are that of the individual author, and not that of Marand Custom Solutions. This site is an open forum for technical content, and the company accepts no liability for any content or view expressed.