LPI Level 1 Exam 101

Passed…..barely.  Got 590 out of 800.   Which isn’t that great, but…. got a pass!

echo ‘590/800’ | bc -l
.73750000000000000000

 

Linux vi tricks for converting vertical lists to horizontal comma separated lists

:: Linux vi tricks for converting vertical lists to horizontal comma separated lists ::

I have recently found that I need to do this almost every day. Here’s my little note on how I can do this quickly in vi.

First take your list of files vertically sorted and open them in vi.

#> vi myfile.txt
Bob
Joe
Jim
Seth
Sam
Sarah
Bill
Amy
Anne
Beth

—-
Next, tack on a comma to the end of each line with this vi command:

%s/$/,/g

Which gives you this:

Bob,
Joe,
Jim,
Seth,
Sam,
Sarah,
Bill,
Amy,
Anne,
Beth,
—-
Once you have all your lines ending in a comma, remove all the line breaks from the end of each line with this vi command:

%s/\n//

Which gives you this:

Bob,Joe,Jim,Seth,Sam,Sarah,Bill,Amy,Anne,Beth,

—-
Done.

I have been using this mostly for converting lists of IP addresses to comma separated for use in Linux Fabric scripts.

Enjoy!
K-Dog

:wq

Yay Linux! Using tar to pull and compress a directory from a remote server

#### Using tar to pull and compress a directory on a remote server. ####

I have a remote server which has /u01 and /u02 mount points on it. This server keeps dying before the night DBA can get into it to grab files for a rebuild.

I wanted to pull down both the /u01 and /u02 directories, to preserve them. I initially used rsync for it’s “restartable” characteristics. This didn’t do what I wanted as far as preserving permissions, so I decided to use the tar utility. The remote server does not have enough free space on it to create the tar and then copy it off. So I used tar and ssh to compress, pull down and create the tar.gz on my local machine.

After looking around and finding a bunch of to complicated solutions, I came upon a simpler command string.

So this is what I did.
(Kev, remember this as it is useful!)

—-

ssh root@srv03 ‘tar cvfz – /u01’ > /kftmp/srv03_u01/srv03_u01.tgz

—-

Since the was a directory that my regular use does not have full access to I did have to enable root ssh. This was disabled right after the transfer.

I ended up with a tar gz file on my local system which, while owned by me, had preserved the file ownership and permissions of the original /u01 file system.

—-
root@SoftKitty:/kftmp# ls -lh srv03_u01/
total 396M
-rw-rw-r– 1 kfitzgerald kfitzgerald 395M Aug 3 17:38 srv03_u01.tgz
root@SoftKitty:/kftmp#
—-

Yay Linux!
K-Dog. The_Kev
:wq

God, internet you are shit! So shit!

What’s the point of 50M down when I can’t stream my gangster rap yo? And what do I do when it stops.. I push play… then it works for a minute.. then it dies.. again… 50megabit down…

So I try this about 3 more times, then notice:

I'm an idiot.

I’m an idiot.

Uh no bitch, I’ll prove it!

df -h

Filesystem Size Used Avail Use% Mounted on
 /dev/sda5 21G 20G 952K 100% /
 udev 2.9G 4.0K 2.9G 1% /dev
 tmpfs 585M 1.3M 584M 1% /run
 none 5.0M 0 5.0M 0% /run/lock
 none 2.9G 57M 2.8G 2% /run/shm
 /dev/sda2 268G 5.6G 249G 3% /disk1
 /dev/sda1 100M 26M 75M 26% /media/System Reserved
 /dev/sdb1 1.9T 1.5T 343G 82% /media/Elements

Well shit.

du -sxch /*

8.5M /bin
 69M /boot
 4.0K /cdrom
 4.0K /dev
 5.4G /disk1
 16M /etc
 15G /home

What is in /home… why so FULL????

du -sxch /home/*

du: cannot access `./erin/.gvfs': Permission denied
 15G .
 15G total

Got it.. ok

/home# du -sxch /home/erin/*
 4.4G total

Wait wait…

ls -l /home

total 4
 drwxr-xr-x 59 erin erin 4096 Apr 20 21:02 erin

Why no work…. Back up plan:

du /home/erin/* | sort -nr | head -10

14825504 .
 8532376 ./.local
 8532372 ./.local/share
 6449640 ./.local/share/Steam
 4694904 ./.local/share/Steam/steamapps
 4694872 ./.local/share/Steam/steamapps/common
 4280152 ./Downloads
 2535764 ./.local/share/Steam/steamapps/common/Baldur's Gate II Enhanced Edition
 2049492 ./.local/share/Trash
 2049108 ./.local/share/Trash/files

Filesystem walk of shame:

du /home/erin/Downloads/* | sort -nr | head -3

 1388656 setup_zork_nemesis.exe
 1027084 ubuntu-14.04.2-desktop-i386.iso
 956788 setup_zork_grand_inquisitor.exe

Oh wow…Let’s move it to /disk1.. It…….. yes all the zork games….

mkdir /disk1/Downloads
mv *zork* !$

 mv *zork* /disk1/Downloads

 

df -h

Filesystem Size Used Avail Use% Mounted on
 /dev/sda5 21G 17G 2.5G 88% /
 udev 2.9G 4.0K 2.9G 1% /dev
 tmpfs 585M 1.3M 584M 1% /run
 none 5.0M 0 5.0M 0% /run/lock
 none 2.9G 34M 2.9G 2% /run/shm
 /dev/sda2 268G 8.0G 246G 4% /disk1
 /dev/sda1 100M 26M 75M 26% /media/System Reserved
 /dev/sdb1 1.9T 1.5T 343G 82% /media/Elements

Can I play music? Ugh.  Yes.

Resize of LUN presented to OVS Hypervisor Host and VM

K-Dog’s notes on this wonderful procedure:

This is what I had to deal with earlier this week.

—-

INTRO:

BRAINDUMP
1- ovs
2- NFSserver
3- guest

[Read more…]

INCIDENT REPORT – 14/15 JAN 2015

An incident has occurred and will be documented for yearly review.

Violation:
No Use of Windows OSs. See http://www.fridaynightlinux.com/2015/01/the-2015-challenges-and-their-exceptions/ for further details

Name:
NathantheFake

DOB:
09/xx/1982

Details:
NathantheFake spend hours in Windows 7 outside the allowable uses in the terms of agreement. The majority of this time was trying to play a game known of League of Legends hereby referred to as “LOL”. However the majority of the time was updating Windows 7 to Windows 7 Sp1, then IE to 11 to enable “LOL” login. Upon playing “LOL” nathanthefake’s shitty ass computer reached 100C within 8 minutes causing an immediate shutdown.

Reactions:
Linux was quite upset with this violation and responded accordingly.

downsized_0115052159

Penalty:
Due to only lasting 15 days for a yearly challenge, the punishment must be swift and firm. Nathanthefake’s windows partition has been DELETED.

Repercussions:
Nathanthefakes Linux partition gained a new mount of 249G:

Filesystem Size Used Avail Use% Mounted on
/dev/sda5 21G 17G 2.8G 86% /
udev 2.9G 4.0K 2.9G 1% /dev
tmpfs 585M 940K 584M 1% /run
none 5.0M 0 5.0M 0% /run/lock
none 2.9G 27M 2.9G 1% /run/shm
/dev/sda2 268G 5.0G 249G 2% /disk1

Now Downloading:
Shadowrun Returns
Left 4 Dead 2
Dota 2
World of Goo
Shovel Knight
Portal

Friday Night Linux – The Website About Thursday Night Gaming

Well how about Tuesday Night Linux Gaming! OH SHIT.

Hearts to Steam. Death to Wine Gaming.

BG2_Linux

Do you… Excel?

Well I don’t excel.

Problem:

I had a spreadsheet with many rows and columns in Excel. I wanted to sort a row and get a count of each “S” number. Excel can do this right? Dunno.

Solution:

– Highlight entire column
– Ctrl+C
– vi out.out
– i
– right click
– Escape (twice for good luck)
– :wq!
– cat out.out | sort | uniq -c

21 S1
13 S2
6 S3
1 S5
10 S7L
2 S7M

Performance

Friday Night Linux.. one of the few posts:

linuxperftools

Original Link:
http://brendangregg.com/Perf/linuxperftools.png

BASH Cheat Sheet

Cheater!
So, I like bash(or BaSH or BaSh or whatever). It’s powerful, and it’s Fun! Throughout the years I have picked up some fun shortcuts for the CLI.
This is a running list of some of my favorites (and some which I don’t really use). Disclaimer: this stuff was found on the Internet!

# Bash Cheat Sheet
Here are my most commonly used shortcuts while on the CLI:

Ctrl + a – Jump to the start of the line
Ctrl + d – Delete from under the cursor
Ctrl + e – Jump to the end of the line
Ctrl + u – Delete backward from cursor
Ctrl + w – Delete backward a word

And look at this little gem. How may times have you gone to [Read more…]