Thursday, May 10, 2012

Blog Closed

I use both Linux and Windows 7. I'm deeply satisfied with both of them. Blog closed.

P.S. Thank you, Google, for .blogspot!

Saturday, April 7, 2012

Type Command. Command Type

There are two types of Linux commands:
  1. Shell built-in commands (internal commands)
  2. Files specified in the $PATH variable (external commands)
To distinguish between the two, type in at the terminal emulator:
type cd
and you'll see the following output:
cd is a shell builtin
which states that the command "cd" is an internal command. Try with a typo:
type cf
 and you'll get
bash: type: cf: not found
which means that there's no "cf" file in your $PATH and no "cf" shell built-in. On the other hand, if the same argument is found in both $PATH and as a shell built-in, bash (assuming it's your default shell) will prioritize the shell built-in (it will execute the internal one first). Try this:
type echo
which will simply give you:
echo is a shell builtin
Am I wrong? Why does it display only the internal command? Well, I didn't tell you the whole truth. The command "type" is helpful in many other ways. It can take various options. If you write instead:
type -a echo
you'll see a different output:
echo is a shell builtin
echo is /bin/echo
So passing the option "a" causes bash to display "all" we need in terms of type of "echo". According to the above output, "echo" is both a built-in and an external command (if you want to run the external command "echo", you have to run it like "/bin/echo 'some text'").
Not only this, of course. The "type" command will let us know if a certain command is aliased or not, so the option "a" specifies in its turn if our argument (let's take "ls" this time) is aliased or not (which is very important in some cases). We wanted the whole "type", and nothing but the "type", right?
ls is aliased to `ls --color=auto`
ls is /bin/ls
The "type" command can also take the option "t" in case the user wants to know in short (I mean it) what is the type of a certain command. Let's do this:
type -t time ls echo clamd
which should give us:
keyword
alias
builtin
file
that is, "time" is a keyword (shell reserved word), "ls" is an alias, whereas "echo" is a shell built-in and "clamd" (I use a Linux antivirus) a disk file. It would have given us "function" if the argument had corresponded to a shell function. What if we just want to find out if a "command" is a file or not? Let's replace "t" with "p":
type -p time ls echo clamd
which should prompt you (if you have clamav installed) with:
/usr/sbin/clamd
Why? Because only "clamd" is of type "(disk) file". What if I really need to know the path of all the specified Linux files? Then I will use the big "P":
 type -P time ls echo clamd
which will result in:
usr/bin/time
/bin/ls
/bin/echo
/usr/sbin/clamd
How nice to have what you need and when you need, isn't it?
Why does "type" state that "time" is a keyword? Isn't everything on Linux a file? Of course it is. What "type" serves at (i.e. it draws distinctions between files) does NOT come against the view that everything on Linux is a file, and should NOT be interpreted as such. When you run "type", it will give you the various types of Linux files (according to the roles they play in the system), and disk file is one of these (in this context).

Tuesday, April 3, 2012

It Looks Like a Comment. Is It???

What's that thing
#!
in this
#!/bin/bash
echo "Hello world!"
bash script? Is it a comment? I knew that comments began with "#", so it must be a comment.
No, it isn't. It's a...kind of magic, i.e. a two-byte magic number. It's called the sha-bang (sharp[#] and bang[!]) and it's placed at the beginning of each script. It is a magic pattern that refers to a certain file type. If you want more, consult the manual:
man magic

Thursday, March 29, 2012

Alt+F2 in Gnome 3

I installed the Gnome 3 shell on Ubuntu Oneiric and noticed that the Alt+F2 combo produces no output. Normally it opens a tiny run window.

So...how to handle it? Use the "magic corner" on the right of your display (at the right top of "Activities") to invoke the Activities menu, then search for "keyboard" and click on the "Keyboard" icon, select the "Shortcut" tab >> System >> Show the run command prompt - you will see that it's disabled, so click on the line and press "Alt+F2" to re-enable it.

The Alt+F2 combination is very useful, as it could be even faster than opening the terminal and running a certain program. It acts as a mini-CLI (with limited functions, of course).

Sunday, March 25, 2012

weechat

I've been testing for a while weechat and decided to switch to it permanently. Why? It's simply a matter of taste. To be more specific, I found three features to be convincing:
1. it's very user-friendly (which is amazing for a TUI IRC client);
2. it has a built-in nicklist (very helpful for an XChat/Konversation/KVirc fan like me)
3. includes support for dozens of commands and rivals irssi

You can download weechat from the official website http://www.weechat.org/download/stable/ 

Thursday, March 22, 2012

What is scrot?

It's not what you think...it's a command line app that lets you take screenshots of your desktop. How can you use it? Very easy. Open your terminal and write down the following:

scrot -c -d 7 deskscreenshot.png
This prints the screen within 7 seconds after you've typed the command. It saves the file in the current directory. You can see below a screenshot with BitchX running on Macbuntu (Guake set to real transparency).


Tuesday, March 20, 2012

BitchX and Xterm

A new BitchX is on the road, though the exact date of the public release is not known (you can download the development source as described in the above link). I can hardly wait it! BitchX is one of the best ncurses-based IRC clients ever and I'm very happy that the project is still alive, because BitchX has a tremendous history and it's highly configurable!
Now, about the topic bar :) I had to ask on EFNET, channel #BitchX (and wait for a while...) about displaying the whole topic in a top status bar, as I couldn't figure out myself. You can find here how to display the topic of the channel in a status bar at the top of the terminal when using BitchX (on a single line, of course). However, when the topic is too large, you can't see it entirely displayed. There is no "topic flow" available for the moment (as in weechat, another ncurses irc client, for example), but caf (the actual maintainer of BitchX who gave me the answer) promised to write it down on a "TODO-list". That's also a positive thing: when developers are opened to suggestions and ready to improve their work anytime, the project itself is seen with good eyes.
So...alternatively, you can use xterm to display the topic in the title bar. That doesn't exactly solve the issue, but whenever you scroll over the terminal window you will see the whole topic displayed (unfortunately I don't know how to modify the size/properties of the xterm/ urxvt title bar). How to do this? Well, just like that:
/set xterm_title on
/fset xterm_title $channel($2)->topic
Then you'll see the topic in the xterm title bar. Thanks to caf for this tip!