command line

OpenVMS – Command line editing

DCL implements command line editing and recall, so that users can more easily correct typing errors and reuse previous command lines.

Recall buffer: access to recently issued commands

$ RECALL string Bring up last command beginning with string.
$ RECALL/ALL Displays all commands and their numbers.
$ RECALL number Use a number found in RECALL/ALL.

Command line editing (if it isn’t on, do: $ SET TERM/LINE):

$ {up-arrow} Previous command in recall buffer.
$ {down-arrow} Next command in recall buffer.
$ {Ctrl A} Toggle insert/overstrike editing.
$ {Ctrl D} Move one character left.
$ {Ctrl E} Move to the end of the line.
$ {Ctrl F} Move one character right.
$ {Ctrl H} Move to the beginning of the line.
$ {Ctrl J} Delete word left of cursor.
$ {Ctrl R} Rewrite the command line.
$ {Ctrl U} Delete line left of cursor.
$ {Ctrl X} Cancel the current command line.


$ {Ctrl 3} ASCII code for {Esc}.
$ {Ctrl I} ASCII code for {Tab}.
$ {Ctrl Z} Tell DCL "end of file". Used in some programs
to indicate more general sorts of "end" commands.

Of these, only {Ctrl I} will insert a character into the command line,
rather than just move the cursor around. No new characters may be
inserted before a tab ({Ctrl I}) in a command line, but existing characters
may be changed in overstrike mode, or deleted. This behavior is documented in the “I/O User’s Guide” and has existed since VMS 4.0.

Windows – Change IP from command line

Yes, is possibile don’t make lot of click to reconfigure network interfaces under Windows, using “netsh” command like this:

For set up static address and metric 1 gateway:

netsh interface ip set address name=”Local Area Connection” static ip.ip.ip.ip 1

For set up static dns:

netsh interface ip set dns “Local Area Connection” static xx.xx.xx.xx
netsh add dns “Local Area Connection” addr=xx.xx.xx.xx index=2

For setup ip by dhcp:

netsh interface ip set address name=”Local Area Connection” source=dhcp
netsh interface ip set dns name=”Local Area Connection” source=dhcp

Linux – Send mail from command line

The Linux command line can be very powerful once you know how to use it. You can parse data, monitor

One of major drawbacks of using the mail command is that it does not support the sending of attachments. mutt, on the other hand, does support it. I’ve found this feature particularly useful for scripts that generate non-textual reports or backups which are relatively small in size which I’d like to backup elsewhere. Of course, mutt allows you to do a lot more than just send attachments. It is a much more complete command line mail client than the “mail” command. Right now we’ll just explore the basic stuff we might need often. Here’s how you would attach a file to a mail:

# echo "Sending an attachment." | mutt -a -s "attachment"

This command will send a mail to with the subject (-s) “attachment”, the body text “Sending an attachment.”, containing the attachment (-a) Like with the mail command you can use the “-c” option to mark a copy to another mail id.
Shell scripting:
Now, with the basics covered you can send mails from your shell scripts. Here’s a simple shell script that gives you a reading of the usage of space on your partitions and mails the data to you.

df -h | mail -s "disk space report"

Save these lines in a file on your Linux server and run it. You should receive a mail containing the results of the command. If, however, you need to send more data than just this you will need to write the data to a text file and enter it into the mail body while composing the mail. Here’s and example of a shell script that gets the disk usage as well as the memory usage, writes the data into a temporary file, and then enters it all into the body of the mail being sent out:

df -h > /tmp/mail_report.log
free -m >> /tmp/mail_report.log
mail -s "disk and RAM report" < /tmp/mail_report.log

Now here’s a more complicated problem. You have to take a backup of a few files and mail then out. First the directory to be mailed out is archived. Then it is sent as an email attachment using mutt. Here’s a script to do just that:

tar -zcf /tmp/backup.tar.gz /home/leo/files
echo | mutt -a -s /tmp/backup.tar.gz "daily backup of data"

The echo at the start of the last line adds a blank into the body of the mail being set out.