Linux Ask!

Linux Ask! is a Q & A web site specific for Linux related questions. Questions are collected, answered and audited by experienced Linux users.

Move cursor to the end of the line in your shell

Answer:

In our previous article we learned how to move cursor to the start of the line, so how about the end of the line?

Answer:

Ctrl + e

Move cursor to the start of the line in your shell

Answer:

Assume you have typed a long command, how to move to the start of the line?

The answer is..

Ctrl + a

Echo without a newline at the end

Answer:

Normally when you use the echo command to print a string, it will append a newline at the end of the string. To skip the newline, you can try using the "-n" argument.

# echo -n "hello"

Exclude files when using the du to estimate disk usage

Answer:

It is easy to use du command to estimate disk usage, however, sometimes you want to ignore some files during the calculation.

To do so, try

# du -h --exclude='*.bak'

The above command will exclude all the file end with the extension .bak during the disk space calculation.

Edit a remote file with vim over SSH

Answer:

If you have a remote file and you can have a quick edit, if you use the following command:

# ssh -t john@remote-server vim /data/test.txt

You will be prompted to login if you don't have proper ssh key in the remote server, and after finishing editing the file, you will quit the ssh session automatically.