Skip navigation.

Beyond the Sky

The place where surface stop and share the experience of life

Posts tagged with "command"

Linux By Example

, , , ...

Linux By Example (LBE) started at July 2006, until today, it contains almost 100 examples on over 100 of GNU/Linux commands. The first version of LBE was tested at http://mysurface.no-ip.org/blog, and lately the entire blog shifted to http://lne.blogdns.com/lbe. We registered a web redirection service at co.nr to get a redirection with easy remember's web address, the URL is http://www.linuxbyexample.co.nr

The idea of showing gnu/linux command by using examples is to guide new user to have better understanding of the basic usage of a command and adapt to use it instantly. We are always recommend users to try out the command for more capabilities by go through the manuals. But usually a useful command always come with a very technical and lenghty manual. These manual sometime scares a new user away, because they couldn’t instantly find an example for just trying out. Manuals are meant for reference, example are meant for learning. We learn well by refering to various examples.

I always pity the beginners who are so lost when start off linux command line, who asking questions in IRC or in forums and get the respond "RTFM". RTFM stand for "Read the F**king Manuals", which ask people to "man command" in an annoying manner. The word "F**king" indicate that manual are not easy to read, they are technical, lengthy and some of them are not complete. Anyway, Not all of the manuals are so difficult, some of them have simple example to hands on, some of them are straigh forward and easy to follow. Some lengthy manuals always scared beginners away, because they are not yet cope well with "man". LBE present you various examples and "human" explaination on how you can use the command line. The purpose of LBE is not to stop you from reading manuals. Instead, LBE aims to guide a new user to start off, and lead them to read the manuals when they need further functionality of a command to meet their requirements.

Besides to give an alternative way to understand and use the command line, LBE also gives you ideas on how you can use the command line to do your job. By reading LBE, it does introduce you a useful tools (command line) which you never aware of, or it introduces the other usage of a command line, which you never think of. Combos! How linux user combine few commannds to create wonders. You may discover alternative ways of doing the same job in comments and you are welcome to give your suggestions.

LBE is not just a blog, but it is a space for Linux users to share their knowledge, experiences on using command lines. Please help us to build up the database, we need more linux user for that. You can register as contributor at LBE and can email me personally if you have any question.

What we have besides that?

Mailing List
You can subscribe to get the news and further discussion anything regarding LBE.

Search Plugin
You can add LBE mycroft plugin to your browser search bar. Check out at sidebar of LBE main page and click the link to install.

Random Example
You can get a random example, this return a randome post on our example pool.

Capture flv and play under Linux

, , , ...

FLV, Flash Video.

You may notice nowadays, people digs video sharing. Thats why www.youtube.com are so famous, where it allocate space for internet user to share videos. If you are regulary surf youtube, you may relized that the video hardly play realtime, it takes sometimes to buffer the download. Sometimes you really like the content of the video, and wants to download and keep it for future replay.

Now you can with just install a add-ons for firefox. VideoDownloader enable you to download videos from Youtube, Google, Metacafe, iFilm, Dailymotion... and other 60+ video sites ! And all embedded objects on a webpage (movies, mp3s, flash, quicktime, etc) ! Directly ! check out this web
https://addons.mozilla.org/firefox/2390/

Now after you downloaded, you try to play using xine or mplayer and figure out that there are no sound. This problem exist until today. There is a work around solution, convert flv to mpg format. With ffmpeg, the conversion is simple. Let say you download a file temp.flv and you would like to convert it to mpg, you can consider bellow command line.

ffmpeg -i foo.flv -ar 22050 -b 500 -s 320x240 foo.mpg 


To ease conversion, I write a bash script:
#!/bin/sh
if [ -n "$1" ]
then
        if [ -n "$2" ]
        then
                ffmpeg -i $1 -ar 22050 -b 500 -s 320x240 $2
        fi
else
        echo "Usage: `basename $0` source.flv target.mpg"
fi

nbtscan

Searching for tools to catch the person who steal IP, which makes IP conflicts happen, the easy tools to get netbios name and MAC address is using nbtscan.

By easily type

nbtscan <ip addr range>


It will shows you the info you want it.

xprop and pgrep

,

While surfing through fluxbox wiki, I learn this 2 interesting commands xprop and pgrep.

xprop are use to display the property for any X item, you can just type xprop at your terminal and click on any X item you like to check the properties. You can type xprop -root to check the root windows properties and also other active programs, for example gaim.

 xprop -name gaim

To grep the process ID for the active 'gaim', you can put
 xprop -name gaim | grep PID


Here comes in another command with more simple result which returns you only the pid.
pgrep gaim


Bare in mind, if you have multiple same services running, it will return a list of pid, let say apache2. To kill process based on the id, now you may do so with
kill `pgrep gaim`

It always have another way to do it, simply killall gaim will do the same thing. But pgrep did more than that, you can list all process created by root user with

This will list all the process running by root with the process names.
pgrep -l -u root


Combine ps and pgrep to display the details of a process with name apache2
ps -fp `pgrep -d' ' -x apache2`


This 2 lines does the same thing as above.
ps aux | grep apache2
ps -fp $(pgrep -d' ' -x apache2)

Fail to access using ssh

, ,

I facing the problem of accessing a server using ssh, which the ssh conplain that I might be ear drops. The reason is i change the server ip to another server. Let say server A uses 202.188.0.1, because server A is down, so i setup another server B uses 202.188.0.1. From the remote site, when i ssh to 202.188.0.1 it do discover that the server have been changed, so it do not allow me to continue ssh.

The fastest hack, i remove ~/.ssh/known_host, then it allow me to ssh again. But some how this is not the right way. I do vi known_host, it do contains multiple entry because i do ssh to many server, i do not have any ideas which to remove. Wandering is there any way to resolve that, because if I delete known_host, all authetications for all server will gone.

Linux Shell Script Issues

,

By right sh file.sh #Let say file.sh enabled mode execution
and ./file.sh is the same. But I do discover if to execute shell script using ./ and sudo, it doesn't work as expected.

For example i have a script needs sudo, you need to run it by using command sh.
sudo sh file.sh

or else if you uses sudo ./file.sh it won't work.

Another example, if ur script contain 'sudo' it won't works as well using ./

But why? because of security issues? or bugs?

alias make perfect

,

Almost every time i need to type sudo infront apt-get, and also when i need to vi configuration files. Tired of typing sudo everytime, I add alias into .bashrc

alias apt-get='sudo apt-get'
alias vis='sudo vi'


Now, i can just type apt-get install and type vis /boot/grub/menu.lst :smile:

Fastest way to stop denial-of-service

,

If you are using linux, the fastest way to stop the attackers from attacking ur network, you forward the traffic to loopback just like this

route add attackers-ip lo


If you are using Window OS, restart your computer, change ur dynamic global IP. If your IP is static, good luck !

Dig a hole

,

It is a command call dig, where you can dig a hole to get infomation.

dig google.com ANY


write, talk and wall

,

I am searching these function for sometimes, in order to write user a message, you can use write.

Let say you was unable to call ur fren, maybe he forgot to bring his cellphone and you know he is in the linux server room doing something, and you have permission to ssh to a particular server, then you can write him a message.

First of all, type "w" or "who" to check is he log on to the server and on which console. Let say he is on /dev/pts/1, so write him a message with

write hisname /dev/pts/1


you can start write your message now and end it with CTRL+D.

To have conversation both way check out talk.
To 'broadcast' to everyone on the server check out wall.
December 2009
S M T W T F S
November 2009January 2010
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31