To create a specific sized file, dd command can be used. Example below will create a file named output with 10M size:
-rw-r--r-- 1 user user 10M 2009-11-14 06:21 outputLinux is for everybody. Lets enjoy it.
To create a specific sized file, dd command can be used. Example below will create a file named output with 10M size:
-rw-r--r-- 1 user user 10M 2009-11-14 06:21 outputTo split big files, split command can be used. Below is command used to split 400MB file named bigfile into 100MB chunk files named smallfile0*
Sometimes you found a website that is very interesting, but you just do not have enough time to read it on that particular time. You wish you could save it so that you can view it offline without connecting to the internet. This can be done using wget;
$ wget -m -k -K -E http://www.tldp.org/HOWTO/LVM-HOWTO/index.html
where -m for mirror, -k for convert the links so that it will be suitable for local viewing, -K for backup converted files and -E for adding html extension to the files downloaded. This is the result of the above command;
$ ls
www.tldp.org
Use any web browser to view the files offline by opening the .html file inside the above folder
When you have logged to your machine through ssh, this is what you will always see after each successful access:
Last login: Tue Jun 3 13:17:35 2008 from 10.20.20.171
[user@server ~]$
You can have additional message displayed like this, by using message of teh day (motd):
Last login: Wed Jun 4 14:59:13 2008 from 10.20.20.241
This is a my server!!!!!!
[user@server ~]$
Here are the steps to do it:
Sometimes when you run a command, you need to see the progress of the command, yet you do not want to keep refreshing the command by repeating it a few times. There is a useful command in linux that can do the job of refreshing for you which is watch. According to the watch man page: "watch - execute a program periodically, showing output fullscreen". By default watch will refresh the command in the interval of 2 seconds but this can be changed according to your needs.
For example, you want to see the memory usage of your computer every 2 seconds:
$ watch free -m
This kind of output will show:
(Click on the image for clearer view)
To set the interval(15 seconds) which watch will refresh, use -n option:
$ watch -n 15 free -m
The output:
(Click on the image for clearer view)
To see the differences of each refresh session, use -d. Watch will highlight the changes that happening on that particular moment:
$ watch -d free -m
(Click on image for clearer view)
To exit from watch, just use your trusty Ctrl-c
To remember every commands in linux is a very tough job. Even experienced user cannot boast that they have remembered every single command. To get help about commands in linux, a few commands can be used.
Extracting tar is a common thing to do and everybody familiar with unix and linux knows how to do it. Usually the files will be extracted to the current directory. There is although one small trick to do to send the files to the desired location. Use the below command:
# tar -xvzf filename.tar.gz -C /desired/path
This command will extract(-x) verbosely(-v) tar gz(-z) file(-f) to the desired location. Hope this will help. Cheers
To view text in linux, there are several tools that one can use. The purpose of the text viewer is to view the text file and not editing it. Some of it also equipped with search function to ease reading.
If you are using GUI, you can use gedit, which is available if you are using gnome desktop environment. Gedit works as both editor and viewer. If you are using KDE desktop, you can use KEdit.
In the absence of GUI, a few tools can be used, such as less and more. These 2 tools is quite similar with only the difference in name.
To use less:
# less filename
and similarly to use more:
# more filename
Another tool that can be used is cat. Cat's purpose is to concatenate 2 file into one, but if used to a single file, cat will display the file to standard output. To use cat:
# cat filename
To send message to a particular user, you have to know what is the user tty. You can do this by typing:
# w
This command is used to show who is logged on and what they are doing. The output of the above command is usually like below(Click to see the image clearly):
To send message to a specific user:
$ write username tty
Example, to send message to user user1:
$ write user1 pts/3
Write you messages, and then press Ctrl-d to exit 'write'
To send message to all connected user, use wall command:
$ wall
Type your message and Ctrl-d to exit 'wall'
To set system clock and date using command, date command can be used.
This is how to do it:
-> date mmddttttyyyy.ss where;
mm - month
dd - day
tttt - time in hours and minutes
yyyy - year
ss - seconds
For example, to set the current date to 17 July 2007, 11:15 a.m., this command below can be used:
-> date 071711152007
To see the current date, the date command without argument can be used.
-> date
Unlike most non-unix operating system, Linux have many runlevels. They are numbered from 0-6 like below.
0 - halt
1 - Single user mode
2 - Multiuser, without NFS (The same as 3, if you do not have networking)
3 - Full multiuser mode
4 - unused
5 - X11
6 - reboot
This list is taken from /etc/inittab file where init will find its configuration setting. The default runlevel usually is set to runlevel 5 where it is the graphical mode of linux. Halt means shutdown and runlevels 1-3 are non graphical mode. You can switch your runlevel by using;
-> init
To check your current runlevel, you can use;
-> runlevel
To view this list;
-> vi /etc/inittab
If after you have installed media player amarok, and the player cannot play mp3 files, you have to install one more library: libxine-extracodecs
Run
-> sudo apt-get install libxine-extracodecs
or
use synaptic package manager to install the library
To search for a string in all files from the given directory, grep command can be used. Type:
-> grep -R "string" /path
For example, to search for string "default" in /tmp directory, use this command:
-> grep -R "default" /tmp
Below are the steps to be taken to change your default editor. Usually for Ubuntu, the default editor is pico and for Centos is vi.
This is how you can format your flash drive(thumbdrive, pendrive) in any linux machine
1. To see what is the filesystem for your flashdrive
Sometimes we have an iso image in our computer. One of the way to view it is to burn it on a cd and then we can view it. The other method is we can use mount command.
Type this command on terminal:
-> mount -o loop filename.iso /path/to/directory
where;
/path/to/directory - directory where you want to deploy the iso
filename.iso - name of the iso file
If you are using a pc with linux that does not have automount feature, here are the steps that you can do to mount it on linux terminal.
Sometimes you want to know the particulars about the kernel of your linux. This can be done using uname command.
To check kernel version:
->uname -v
To check kernel release:
->uname -r
To check kernel name:
->uname -s
To view running processes, you can use ps command to list out the running processes.
To see every process on the system:
ps -e
ps -ef
ps -eF
ps -ely
To find the process that you want to see:
-> ps -e | grep nameoftheprocess
example: -> ps -e | grep httpd
The above command will print only the httpd process.