Search This Blog

Showing posts with label Useful Commands. Show all posts
Showing posts with label Useful Commands. Show all posts

Thursday, May 5, 2011

Useful Commands, a script to keep your ssh session alive

Sometimes you don't have the permission to modify your sshd.conf. Just run a simple scrip forever to keep your ssh session alive:


sh  -c 'while echo "alive" > /dev/null; do sleep 20; done' &

Friday, April 22, 2011

Useful Commands, swapoff swapon

If you know what you are doing, and you would like to flush your swap memory.

flush the swap:
swapoff -a

turn on the swap:
swapon -a

Tuesday, March 29, 2011

Useful Commands, ntpdate

The time in your FreeBSD is out of sync? Or you are under Daily Saving Time that you want to adjust your clock? Just run ntpdate to update your machine clock with network time protocol.


ntpdate 0.pool.ntp.org

more ntp timer server can be found here:
http://support.ntp.org/bin/view/Servers/NTPPoolServers
http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/network-ntp.html

Friday, February 18, 2011

Useful Commands, Mount FreeBSD ufs in Linux

Linux supports read on FreeBSD ufs filesystem.
You can mount them with:

sudo mount -r -t ufs -o ufstype=ufs2

for example:
sudo mount -r -t ufs -o ufstype=ufs2 /dev/sdb1 /mnt

Thursday, December 30, 2010

Useful Command, vidcontrol for Console Resolution

Most of us have a decent LCD monitor and it will be nice that we can use the high resolution inside the console. Under FreeBSD, it was not possible for AMD64. From FreeBSD 8 Stable and forward, the vesa driver is supported in the kernl option! Thank you for the FreeBSD team. This is such a nice work. To enable vesa for the console, add this to your kernel config file:

options VESA
options SC_PIXEL_MODE

and install your new kernel. After that you can check with vidcontrol -i mode, you can see several high resolution available. To use a 800x600, do:

vidcontrol VESA_800x600

check the manual page for vidcontrol, you might need to load different fonts for different screen resolutions.

reference:
http://www.freebsd.org/doc/en/books/handbook/consoles.html
http://forums.freebsd.org/showthread.php?t=9449

Wednesday, December 29, 2010

Useful Command, kbdcontrol

Usually the keyboard repeat rate is not fast in the terminal. Under FreeBSD, you can use kbdcontrol command:

kbdcontrol -r fast

will make your key repeat rate fast.

or add
keyrate="fast"
to your /etc/rc.conf

Wednesday, December 22, 2010

FreeBSD, capture the terminal output

sctip(1) can capture the entire terminal output. This is very useful such as, capturing all the messages after you start your X server, or capturing the entire compiling session.

In the console, just type script /place/to/store/output/file.txt
you can continue your work on this console.
To end it, just type exit on the console.

Tuesday, December 8, 2009

Useful command, sendmail

cat mail.txt | /usr/lib/sendmail -t -X log.txt

mail.txt have the following format: (the -t option)
to:recipient@somewhere.com
from:you@yourdomain.com
subject:Testing 123

This is my message.
and log.txt can log everything in and out. (the -X option)

Friday, October 2, 2009

Useful Command, pgrep and pkill

Sometimes we want to kill a lot of processes with the same name, pgrep and pkill are userful.

for example, to kill all the idle (I) vlc process,
pkill vlc

then if we use pgrep vlc, we can see that all vlc processes are removed.

Monday, September 21, 2009

Useful Commands, Soft Link

ln -s (target, your actual file) (symbolic link, referencing to the actual file)

say you are missing libz.so.5 in your system and your program requires it. A quick walkaround is to let libz.so.5 work as a symbolic link to another libz.so, e.g.

ln -s /lib/libz.so.6 /lib/libz.so.5

Soft Link
ln -s /directory/of/application/ /directory/and/softlink

e.g. ln -s /usr/local/apache-tomcat /usr/local/apache
This created an ‘apache’ softlink to apache-tomcat directory

ls -l
apache -> /usr/local/apache-tomcat

To use hard link, just remove the -s option

Wednesday, September 2, 2009

Useful Command, Check If SSHD Is Running

To check if your ssh server is running, easily type,
ps -A | grep sshd

It can also check if other servervices are running too, like ftpd, httpd, etc.

Sunday, August 2, 2009

Useful Commands, List Top Ten Largest Files

du -a -h /home/bps2/Desktop | sort -n -r | head -n 10

Print as human readable format.
Play with du(disk usage), sort, and head commands together.

Useful Commands, List The Partition Table with fdisk

fdisk -l can list the partition table information.
Sometimes it is useful to run the above command on a dual boot system.
For example, under Linux we can see the information, and mount the Windows partition.
mount /dev/sda1 /media/c

Wednesday, July 22, 2009

Useful Commands, Split Files Using Winrar with Command Line

rar a myfile.rar myfile.iso -v500m

a, create an rar archive
myfile.rar, name of your newly created rar
myfile.iso, file(s) you would like to archive
-v, how would you want to split
500m, 500MB split

Useful Commands, Update Software in Ubuntu

In Ubuntu, you can update and install software quickly and easily with apt-get and aptitude

sudo apt-get update (refresh the latest packages from your /etc/apt/sources.list)
sudo apt-get upgrade (update the latest package(s))
sudo apt-get install your_software (install the individual package)

sudo aptitude search your_software (search the package)

Tuesday, July 7, 2009

Useful Commands, Truss to Trace System Calls

Truss(1)

To learn more about system call, we can use truss to trace system call on a process.


Sunday, July 5, 2009

Useful Commands. Mount USB key in FreeBSD7

Mount USB key in FreeBSD7

/etc/rc.conf (load modules at boot time) (or recompile the kernel) usb_load="YES" umass_load="YES"$

insert flash key, da0 should show up on the console when typing dmesg

mount_msdosfs /dev/da0 /mnt (make sure the directory /mnt is there already)

(take a look at /dev, and make sure the mount directory is there)

Monday, June 8, 2009

Useful Commands

more:
'/' to search, 'n' to search the next
'v' to bring up the editor
'g' + line , go to line

Emacs:
M-g g: go to line

+: mkdir (in Dired mode)

R: rename file (in Dired mode)
C: copy file (in Dired mode)
e: edit file (in Dired mode)
d then x to confirm, u to unmark: delete file (in Dired mode)

Reference: http://www.astro.ku.dk/comp-phys/tutorials/emacs.shtml

Vi:
                                  (up)  

k
(left) h l (right)
j

(down)
x is to delete

i: insert, (use Esc to escape)
':', type command, w is to write



Subversion:
Diff with previous version:
svn diff -r #(revision number) | more

See historical change of each line:
svn blame /usr/src/sys/net/if_gif.c | more

mixer:
change volumn