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.

Jun 152010
 

Specify a port with the scp command

Answer:

If you want to use scp to copy file to remote machine, but that ssh server is listening at port other than 22, you can use the following command syntax.

# scp -P 6000 test.txt john@remoteserver:/home/john/

Please notes it is -P, not -p.

Jun 142010
 

Create ISO image from CD-ROM in Linux

Answer:

1. Put the CD in your CDROM

2. umount the CD if it was mounted automatically (assume the current mount point is at /mnt/cdrom, you can type the mount command to check if your are not sure)

# umount /mnt/cdrom

3. Create the ISO image

# dd if=/dev/cdrom of=/tmp/cd.iso

Jun 132010
 

How to easy remove file with strange file name?

Answer:

Sometimes, you have a file with strange file name and you want to remove, e.g. -test.txt,

e.g.

# rm -f -test.txt

rm: invalid option -- 't'
Try `rm ./-test.txt' to remove the file `-test.txt'.
Try `rm --help' for more information.

Another easy way is delete by inode.

# ls -il *

983076 -rw-r--r-- 1 john users 0 Jun  4 21:24 -test.txt

And finally delete it

#  find -inum 983076 | xargs rm -f
Jun 102010
 

List 10 most often used commands

Answer:

You can list the top 10 most often used commands in your Linux, by the following method.

# history | awk '{a[$2]++}END{for(i in a){print a[i] " " i}}' | sort -rn | head 

135 ls
63 cd
48 exit
46 sudo
34 tail
30 cat
29 df
18 date
17 vi
12 pwd