Stickies : Linux - FreeBSD commands

by Perk1z on July 14, 2007

Disk, filesystem

Disk usage
{linux}$ du -sh
{freebsd}$ du -sh

Count subdirectories in current directory:
{linux}$ du –max-depth=1
{freebsd}$ du -d1

Typical approach to find biggest directories/files on disk:
{linux}$ du –max-depth=1 -kx|sort -n
{freebsd}$ du -d1 -kx|sort -n

Find some kinds of files (regex is a mask for full path, no need for begin/end marks)
{linux}$ find . -regextype posix-extended -type f -regex “.*\.(java|class)”
{freebsd}$ find -E . -type f -regex “.*\.(java|class)”

Show open files and programs:
{linux}$ lsof
{freebsd}$ fstat

Some networking
Show open ports and apps connected to them:
{linux}$ netstat -apne –inet
{freebsd}$ sockstat

Kernel issues
Show loaded modules:
{linux}$ lsmod
{freebsd}$ kldstat

Load kernel module:
{linux}$ modprobe SomeModule
{freebsd}$ kldload SomeModule

Remove loaded module:
{linux}$ rmmod SomeModule
{freebsd}$ kldunload SomeModule

Program development
Trace the system calls of a program:
{linux}$ strace
{freebsd}$ truss  (strace is also available in /usr/ports/deve/strace)

libraries - show all paths + libs:
{linux}$ ldconfig -p
{freebsd}$ ldconfig -r

Packages management
Different linux distros make it own way. I’ll focus on debian-based distributions like Debian, Ubuntu, Kubuntu etc. Find which package this file belongs to?
{freebsd}$ pkg_info -W /path/to/file
{linux}$

Have we got a package like… (in (k)ubuntu you can use more friendly tools like synaptic, apt-get)
{linux}$ apt-cache search your_name
{freebsd}$ cd /usr/ports; make search key=your_name
just in package names:
{freebsd}$ locate -i your_name | grep “/usr/ports/”

Install a binary package
{linux}$ apt-get install package_name
{freebsd}$ pkg_add -r package_name

Install a package from sources
{linux}$ is there a simple way to do it?
{freebsd}$ cd /usr/ports/path/package; make install clean

Popularity: 13% [?]

Share and Enjoy:
  • Digg
  • del.icio.us
  • Facebook
  • Google
  • LinkedIn
  • Live
  • Print this article!
  • Slashdot
  • StumbleUpon
  • Technorati
  • YahooMyWeb

Related Posts


Web Hosting Pal - www.webhostingpal.com

{ 0 comments… add one now }

Leave a Comment

You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

*
To prove you're a person (not a spam script), type the security word shown in the picture.
Anti-Spam Image