Copying Files in Linux bash shell

So you want to copy a file in Linux? Easy enough.

cp filename newfilename

But sometimes it isn’t so easy… Say the file you want to copy begins with a .

You can’t see these files unless you add -a to your ls command

ls -la
.bashrc
.bash_profile

Once you can see the file, you can copy it as follows:
cp .bashrc .bashrc2

Not so bad, but if it starts with a hyphen it requires special handling to prevent your shell from thinking you are passing a parameter to the cp command. You’ll need to precede the filename with a ./ as follows:

cp ./–filename newfilename

Another difficulty with copying files is when someone has either intentionally or unintentionally created a file with a non-viewable ASCII character in the name. Say, for instance, someone has created a file with a name preceded by an ASCII space or the name is only an ASCII space. How do you delete that file? The same way as we copied a file starting with a hythen above.

rm ./ filename

you can also use rm -i to force you to verify the deletion for extra protection.

Posted in Linux | Leave a comment

vi stuff

” at top of paragraph, format this paragraph
!} fmt -c

” for the whole file, format all paragraphs
!G fmt -c

“from here to the end of the file, format all paragraphs
!$ fmt -c

” from anwhere in the paragraph, format this paragraph
{!}fmt -c

Here’s how I map them in my .exrc file:
map @f !} fmt -c^M
map @F !G fmt -c^M
map ^Xf !$ fmt -c^M
map ^XF {!}fmt -c^M}^M

#To delete all lines which contain the string tornado watch:
:g/tornado watch/d

#To comment out all lines between line 6 and 22
:6,22 s/^/#/

#To run a python script inside vi
:!python script.py

Posted in Linux | Leave a comment

Disaster Recovery Planning

HARDWARE

Document computer assets internal to organization
Document external components like bridges, switches, routers, cables, and connectors
Document redundancy setup for critical hardware and services

DATA RESTORATION

Document backup process to specify the following as a minimum:

a) storage devices to be used
b) whether backups will be manual or scheduled
c) backup retention, backup storage, and backup rotation scheme to include who is online at scheduled backup time
d) categorize critical data and special processes related to critical data

FireDrill

Create Verification/Test plan for data restoration to include testing usability of backup media

Run through mockup of Data Loss and Restoration at least semi-annually

Posted in Linux | Leave a comment

Using Loopback Command

Loopback filesystem support allows a user to mount an ordinary file as if it were a device, such as /dev/hda1. This is useful for mounting a CD-ROM filesystem to populate and test before burning it to CDROM.

Use the dd command to create file large enough to contain the filesystem:

dd if=/dev/zero of=filesystem.img bs=1M count=20

Associate the new file with the loopback device:

losetup /dev/loop0 filesystem.img

Create a filesystem within the file:

mkfs -t ext2 /dev/loop0

Mount the filesystem:

mount /dev/loop0 mount point

Posted in Linux | Leave a comment

Hello world!

Welcome to the Sovereign Republic of Vickistan. Please to keep your hands and feet inside the country.

 

Posted in Ash and Trash | Leave a comment