dexxtreme

May 242008
 

Sometimes you will need to create a virtual loopback device for whatever reason. One possible need would be for a temporary filesystem to do some quick testing, or maybe to set up a larger /tmp partition on a server where /tmp is too small. To initially create the loopback device, run:

 # dd if=/dev/zero of=/usr/local/tmpfs bs=50M count=10
dd if=<file to read from> of=<file to write to> bs=<byte size> count=<count to loop>

Continue reading “Creating a virtual loopback device” »

May 242008
 

You can use rsync to transfer files from either one directory to another or from one server to another. When copying over large directory structures, rsync is usually better than using cp -av. The cp command copies files and directories blindly, while rsync compares the two directories and only copies the differences. This saves time, hard drive load, system load, and if copying across a network, bandwidth. It is very useful when backing up a hard drive or an entire server. The command to use is:

# rsync -avH –delete –exclude=/junk –exclude=/otherjunk /home /backup/

rsync -avH –delete –exclude=<file/directory to exclude> <source files/directories> <destination directory>

The "a" flag will preserve important settings such as permissions, ownership, symbolic links, etc., as well as recursively copy the entire directory tree. The "v" flag is optional, and will list each file as it is copied and will give a summary of how much data was transferred. The "H" flag preserves hard links (a standard linux installation is often full of these). If you are absolutely sure that you don’t have any hard links in the data you are copying, then you can omit it, but adding it won’t hurt. The "–delete" flag means "delete anything in the destination directory that doesn’t exist in the source directory". This is useful if you are backing up a hard drive and you want to make sure that files that you removed from the main drive are removed from the backup drive as well. The "–exclude" flag allows you to skip over certain directories that you don’t want copied over to the destination directory. You can have multiple "exclude" flags.

If you want to copy your data to another server, then you can use "rsync://<hostname>/<path>" as either the source or destination. The "hostname" is the IP or full hostname of the remote server, and "path" is the exported path that is set up in the rsync configuration on the remote server.

# rsync -avH –delete –exclude=/junk –exclude=/otherjunk /home rsync://backup.server/backup_path

rsync -avH –delete –exclude=<file/directory to exclude> <source files/directories> <rsync://hostname/path>

rsync -avH –delete –exclude=<file/directory to exclude> <rsync://hostname/path> <destination directory>

 

May 242008
 

To list all open network ports on your machine, run netstat -lnptu. Here is a breakdown of the parameters:

l – List all listening ports
n – Display the numeric IP addresses (i.e., don’t do reverse DNS lookups)
p – List the process name that is attached to that port
t – List all TCP connections
u – List all UDP connections

 

 

In this example, there are a number of open ports. For example, you can see:

print server (lpd on port 515)
rsync server (rsyncd on port 873)
database server (mysqld on localhost port 3306)
web server (httpd on port 80)
dns server  (named on port 53)
openssh (sshd on port 22)
syslog (syslog-ng on port 514)
snmp (snmpd on port 161)
dhcp server (dhcpd on port 67)
tftp server (in.tftpd on port 69)
time server (ntpd on port 123)
several services related to importing an NFS filesystem

You can also change the "l" to an "a" to list both listening and active ports.

 

You can also use netstat to show the current routing table by running  netstat -rn:


 


Warning: fopen(/home/dynasty/linuxdynasty.org/wp-content/plugins/wp-google-plus-one/lib/standard.txt) [function.fopen]: failed to open stream: No such file or directory in /home/dynasty/linuxdynasty.org/wp-content/plugins/wp-google-plus-one/plusone.php on line 104

Warning: fread(): supplied argument is not a valid stream resource in /home/dynasty/linuxdynasty.org/wp-content/plugins/wp-google-plus-one/plusone.php on line 105

Warning: fclose(): supplied argument is not a valid stream resource in /home/dynasty/linuxdynasty.org/wp-content/plugins/wp-google-plus-one/plusone.php on line 106
.