Browsing all articles tagged with ubuntu
Jan
17

How to Copy Terminal Session into a File

Have you ever wondered how to copy the output of your terminal into a text file? Or maybe you teach Linux and you want to see what your students typed in and as well as the output? You think that running history is not enough? Then you need the script command.

Running script command

Open the man page of script command and you will see this:

Script makes a typescript of everything printed on your terminal. It is useful for students who need a hardcopy record of an interactive session as proof of an assignment, as the typescript file can be printed out later with lpr(1).

In a nutshell, it is history and tee all rolled into one. It will record everything you see on your screen, even the color. So if you typed in an invalid command, you will see the error in the log or if you run it correctly, you will have the output. But commands like top that refreshes the screen at an interval will most likely ruin the session or the log, so try to avoid similar commands.

To use it, just type the command script and it will begin recording the session. Once you are done, just type exit.

This is script in action:


rai@host1:~> script -a /tmp/script_test.log


Script started, file is /tmp/script_test.log
rai@host1:~> ls /home
R20 r200 R21 rai xx19
rai@host:~> thisnotacommandbutirunitanyway
bash: thisnotacommandbutirunitanyway: command not found
rai@host1:~> exit
Script done, file is /tmp/script_test.log
rai@host1:~> cat /tmp/script_test.log
Script started on Mon 17 Jan 2011 06:24:12 PM PHT
rai@lhost1:~> ls /home
R20 r200 R21 rai xx19
rai@host1:~> thisnotacommandbutirunitanyway
bash: thisnotacommandbutirunitanyway: command not found
rai@host1:~> exit

Script done on Mon 17 Jan 2011 06:24:54 PM PHT

The example above shows that script was started with -a option meaning it will append the output the specified file.

A better way to do this is to use it together with mkfifo command:

On Terminal 1 (Student’s terminal):

rai@host1:~> mkfifo /tmp/script_test.fifo
rai@host1:~> script -f /tmp/script_test.fifo

On Terminal 2 (Teacher’s terminal, same machine):

rai@host1:/tmp> cat /tmp/script_test.fifo

The above scenario will perform the following:
1) On the Student’s terminal, it will create an named pipe /tmp/script_test.fifo (man mkfifo) then run the script command with the -f option that ‘flushes’ out the output after each run. The Student’s terminal will look like it is not responding at this point, but don’t worry, it is perfectly normal.
2) On the Teacher’s terminal, the command cat will read the output file. Once you run the cat command, the session will be started.

Try the above steps and see how each screen behaves. Check also if doing the script command will create a populated output file.

Jan
3

VIM Trick: How to Comment Multiple Lines

If you need to comment out lines of text inside VIM, you can try this trick:

(Enter command mode in VIM)
:40,105s/^/#/g

This will insert the # character at the beginning of each line starting from line number 40 to line number 105.

If you cannot see the line numbers, do this:

(Enter command mode in VIM)

:set number

To remove the lines:
:set nonumber

This is quite handy if you need to comment out lines of codes in a script.

Feb
23

10 Reasons Why Linux will Triumph over Windows

Please, everyone settle down. I am not starting a flame thread here but I would like you to read these ten reasons why Linux will stomp over Windows’s head. TechRepublic writes:

I have an announcement. The error of Microsoft’s ways is finally catching up and will cause the once-invincible juggernaut to kneel before that which is Linux. How is this? Microsoft started a tiny snowball when it released Windows Me. That snowball did nothing but gain momentum. There have been ups and downs along the way (XP being an up, for sure). But for the most part, the court of public opinion has steady lost faith in what once was considered the heart of personal computing.

If you don’t believe me, read on.

1. Inconsistent Windows releases

One of the things you can always count on from Microsoft is that you can’t count on its new operating systems to be reliable. Let’s take a look at the individual releases:

* Windows 95: Revolutionized personal computing.
* Windows 98: Attempted to improve on Windows 95; failed miserably.
* Windows Me: A joke, plain and simple.
* Windows NT: Attempted to bring enterprise-level seriousness to the operating system; would have succeeded had it not taken Steven Hawking-like intelligence to get it working.
* Windows XP: Brought life back to the failing Windows operating system. It hadn’t been since Windows 95 that the operating system was this simple.
* Windows Vista: See Windows Me.

With this in mind, what do we expect from Windows 7? Myself, not much.

2. Consistent Linux releases

Converse to number 1, you have the far more consistent releases of the various Linux distributions. Yes, there have been a few dips along the way (Fedora 9 being one of them). But for the most part, the climb for Linux has been steadily upward. Nearly every Linux distribution has improved with age. And this improvement isn’t limited to the kernel. Look at how desktops, end-user software, servers, security, admin tools, etc., have all improved over time. Once could easily argue that KDE 4 is an example of a sharp decrease in improvement. However, if you look at how quickly KDE 4 has improved from 4.0 to 4.3 you can see nothing but gains. This holds true with applications and systems across the board with Linux.

read more

Jan
27

Windows 7 Features Preview

Windows 7 is getting quite a lot of stirs nowadays. But I am a bit skeptical how Windows 7 is going to be any different from its predecessor Windows Vista. What I want to know is its security features and features that are usable for IT administrators. Actually, when it comes to Windows, I am still biased on its security features. My rule of the thumb for Windows OS’es is “wait for SP2 before buying and installing”. I am still using Windows XP in my computer at home but my Ubuntu still kicks XP’s butt, IMO. But that’s just me.

Anyway, maybe this video will help you get excited for Windows 7.

Sep
13

Linux Evolution

Found another great video of how Linux evolved these past years. Interestingly enough, the video compares the evolution of Windows and Linux. Personally, I like the Windows ‘oops’ videos :D

Anyway, watch the video and enjoy ;)

Powered by 1and1.comDomain Registrations starting at $9.98* Earn with Your BlogAdvertise @ PinoyTux

Search PinoyTux

Subscribe to Email Feeds

Enter Email Address:

Blog Lounge

Popular Posts

Recent Posts

Recent Comments

Site Stats