You can work with filesystems at remote machines as if the were parts of your local system. The magic wand is a sshfs command.
$> sshfs -C username@example.com: ~/example
This command mounts username's home directory at example.com host to local directory ~/example. -C option enables compression to save your internet traffic.
Use the following command to unmount remote directory:
$> fusermount -u ~/example
As usual, for more details see
$> man sshfs
Imagine, you could type the title of this blog in your command line. Here is a possible result of the command.
Thursday, April 22, 2010
Sending an e-mail with attachment using mutt command line interface
Sending an e-mail message with an attachment file using command line interface is a useful operation. It is a convenient way, say, to backup some small files.
$> echo "Hello! This is a backup." | mutt -s "backup" -a '/tmp/backup.tgz' -- 'mail@example.com'
This command sends an e-mail message with a body specified as an argument of echo command ("Hello! This is a backup.").
The subject of an e-mail is given with -s argument (-s "backup").
Attachment is specified with -a option (-a '/tmp/backup.tgz').
Be sure to specify two dashes (--) before an e-mail address ('mail@example.com'), otherwise you get "No recipients specified." message on some systems.
$> echo "Hello! This is a backup." | mutt -s "backup" -a '/tmp/backup.tgz' -- 'mail@example.com'
This command sends an e-mail message with a body specified as an argument of echo command ("Hello! This is a backup.").
The subject of an e-mail is given with -s argument (-s "backup").
Attachment is specified with -a option (-a '/tmp/backup.tgz').
Be sure to specify two dashes (--) before an e-mail address ('mail@example.com'), otherwise you get "No recipients specified." message on some systems.
How to search file in Linux using a locate command
The idea of locate command is straightforward.
If a search pattern does not contain any metacharacters, locate command displays all file names that contain that string at any position of the path:
$> locate yastbrowser
/usr/share/YaST2/yastbrowser
/usr/share/YaST2/yastbrowser/application.ini
/usr/share/YaST2/yastbrowser/chrome
/usr/share/YaST2/yastbrowser/chrome/chrome.manifest
/usr/share/YaST2/yastbrowser/chrome/classic-browser.jar
/usr/share/YaST2/yastbrowser/chrome/en-US.jar
/usr/share/YaST2/yastbrowser/chrome/yastbrowser.jar
/usr/share/YaST2/yastbrowser/components
/usr/share/YaST2/yastbrowser/components/nsCmdlineHandler.js
/usr/share/YaST2/yastbrowser/defaults
/usr/share/YaST2/yastbrowser/defaults/preferences
/usr/share/YaST2/yastbrowser/defaults/preferences/yastbrowser-prefs.js
If pattern does contain metacharacters, locate shows only matching pathes:
$> locate *yastbrowser
/usr/share/YaST2/yastbrowser
If a search pattern does not contain any metacharacters, locate command displays all file names that contain that string at any position of the path:
$> locate yastbrowser
/usr/share/YaST2/yastbrowser
/usr/share/YaST2/yastbrowser/application.ini
/usr/share/YaST2/yastbrowser/chrome
/usr/share/YaST2/yastbrowser/chrome/chrome.manifest
/usr/share/YaST2/yastbrowser/chrome/classic-browser.jar
/usr/share/YaST2/yastbrowser/chrome/en-US.jar
/usr/share/YaST2/yastbrowser/chrome/yastbrowser.jar
/usr/share/YaST2/yastbrowser/components
/usr/share/YaST2/yastbrowser/components/nsCmdlineHandler.js
/usr/share/YaST2/yastbrowser/defaults
/usr/share/YaST2/yastbrowser/defaults/preferences
/usr/share/YaST2/yastbrowser/defaults/preferences/yastbrowser-prefs.js
If pattern does contain metacharacters, locate shows only matching pathes:
$> locate *yastbrowser
/usr/share/YaST2/yastbrowser
Wednesday, April 21, 2010
How to generate strong password in Linux
The simplest way to generate strong password in Linux is to use the pwgen command:
$> pwgen -y
The "-y" parameter instructs the program to include at least one special character in the password.
As usual, for details see
$> man pwgen
$> pwgen -y
The "-y" parameter instructs the program to include at least one special character in the password.
As usual, for details see
$> man pwgen
Tuesday, April 20, 2010
Print information on Ethernet interface in Linux
# ethtool eth0
The command is to be executed in the superuser mode.
It prints information on the Ethernet interface (eth0), such as Wake-on-LAN options, etc.
In order to disable Wake-on-LAN feature execute the following:
# ethtool -s eth0 wol d
The command is to be executed in the superuser mode.
It prints information on the Ethernet interface (eth0), such as Wake-on-LAN options, etc.
In order to disable Wake-on-LAN feature execute the following:
# ethtool -s eth0 wol d
Monday, April 19, 2010
Print desired number of hexdump lines with xxd
$> xxd -l 0xN0 FILE
The command prints the first N hexdump lines (-l 0xN0) of the file (FILE).
The stuff works because each line of xxd output consists of 16=0x10 octets by default, so 0xN0 is the number of octets in the first N lines.
The other useful way to view binary file is the following:
$> xxd FILE | less
The command prints the first N hexdump lines (-l 0xN0) of the file (FILE).
The stuff works because each line of xxd output consists of 16=0x10 octets by default, so 0xN0 is the number of octets in the first N lines.
The other useful way to view binary file is the following:
$> xxd FILE | less
Subscribe to:
Posts (Atom)