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.

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.

Delete files permanently with shred command

Answer:

Sometimes we might need to delete files and don't want it can be recovered.

To do so, use the shred command.

# shred -v -n 10 -u -z test.txt

The above command will overwrite the file 10 times before deleting it.

Import files and directories into a SVN repository

Answer:

To import files and directories into a SVN repository, you can use the svn import command.

E.g.

Import all files and directories under the current working directory "project1" to a local SVN repository

# cd /data/project1
svn import file:///data/svn/project1

Create a SVN Repository on local drive

Answer:

To create a SVN Repository on local drive, you can use the following command:

# cd /data/
# svnadmin create svn

Now you have created a SVN repository located at file:///data/svn/

Create a swap partition using LVM

Answer:

To create a swap partition using LVM, you just need a few commands!

1. Create a 1G swap partition

# lvcreate -L 1G -n /dev/vg0/swap0

2. Set up a Linux swap partition

# mkswap /dev/vg0/swap0

3. Enable it

# swapon -s /dev/vg0/swap0

You might also want to put the settings in the /etc/fstab, so it will be mounted automatically when your system boot next time.

# sudo vi /etc/fstab

/dev/vg0/swap0       none            swap     sw              0       0

Save and restart your system to test if it is working when system reboot.