• Sign in to Neowin Faster!

    Create an account on Neowin to contribute and support the site.

Sign in to follow this  

Things you didn't know you could do with Linux

Recommended Posts

Daishiman    0

The UNIX (and Linux) command line, despite its arcane look, is your greatest friend. Learn it. It's the most powerful tool for managing a computer. There's a reason why UNIX system administrators get by with just this: who really needs a graphical interface when you can get a million times more info and do a million times more with a good ol shell?

NOTE: Mostly oriented towards Debian distros.

-Fast path completion

When you need to navigate to a directory, just type the first few letters of a directory name and press TAB. The rest of the directory will be completed by itself:

Example:

/home/andy/Doc[TAB]

Turns into:

/home/andy/Documents_from_2004

An essential tip.

-Mount ISO images! (Way faster than Daemon tools)

mount -t iso9660 /path/to/iso.iso /mount/point -o loop

-Quake-style terminal!

On Debian/Ubuntu:

sudo apt-get install yakuake

Press F12 and it's good to go!

-Get interesting info on your system:

Uptime

cat /proc/uptime

Get your CPU information

cat /proc/cpuinfo

Get real time process information (ala Task Manager, but better):

top

Change the usage of swap:

nano /proc/sys/vm/swappiness

The number indicates the agressiveness of the use of swap space. Generally there's no need to touch this, but you can always give it a try (remember, BACK UP YOUR FILES!).

Look at your internet interfaces:

ifconfig -a

Look at your wireless interfaces:

iwconfig

-Run Internet Explorer on Linux:

IE4Linux

-Write to your Windows partition:

NTFS-3g filesystem driver

-Run Photoshop CS2 (or at least try)

http://blog.publicidadpixelada.com/2006/10...buntu-10-steps/

-Create and use a file for swap instead of/compliementing a partition:

xxxx= number of 512-byte blocks. For reference, 1000 blocks= 512kB, 2000= 1 MB.

touch /path/to/your/swap 
dd if=/dev/zero of=/path/to/your/file count=xxx
mkswap /path/to/your/file
sudo swapon /path/to/your/file

touch created the file, dd gives it the size you need, mkswap formats it, swapon mkaes it get used for swap.

Check to make sure that it's working with:

swapon -s

The file should be there. If all works there, add this line to your /etc/fstab file:

/path/to/file		none		 swap	  sw	 0		0

And you should be able to use it all the time.

-Get some random numbers/characters/garbage:

dd if=/dev/random count=1 | hexdump -c

This will give you 512 bytes of random garbage. Check the options of hexdump for more variety.

-Look at the functions a program's calling

strace comand_youre_calling args of command

This is a neat little program that shows you the system calls being generated by a program. Pretty nifty and hackerish.

-Get a really friendly shell that text-completes switches and arguments of commands:

On Debian/Ubuntu:

sudo apt-get install fish
fish

Fish is awesome. Forget options and arguments for commands? Just press tab. It's an awesome shell.

-Check out the stuff that's going on in your system

dmesg | tail -number_of_lines_to_show

If you want to know what's going on behind the scenes, dmesg will show you the system log in its current form.

-Syncronize a folder with another folder

Got a portable hard drive with your documents that you take with you? Keep them up to date with your master copy. The best thing is that works across a network too and uses minimal resources, as it only updates files:

rsync -avz --delete /mnt/sourcefolder/ /mnt/backup/targetfolder/

You can try grsync, the graphical version as well:

sudo apt-get install grsync

-Get information on the drivers that are running:

lsmod

Lists the kernel modules (drivers) currently running.

modinfo module_name

Gives you interesting info on it.

As usual, modprobe and rmmod load and unload kernel modules at will.

-Know the type of a file

Since extensions are unnecessary in this side of road, sometimes you may want to know what you're looking at:

file name_of_file

File will guesstimate the filetype of that file. Works extremely well.

-Browse the internet, text-mode!!!

elinks website

lynx website

links website

links2 website

Oh, and when you need to pull a file:

wget html_link

-Find a file:

find /path/to/file -name filename

This command is really worth exploring. Check the man page for it.

-Turn off your computer

shutdown -h now

You can replace "now" with other times. Really great for when you need to leave the machine running for a while.

-Get the hash of a file

md5 file

-Print the nth column of a text file or command output:

cat filename | awk '{print ($x)}'

Where x is the column you want to print, starting from 0.

Instead of cat you can use it on any command you wish

-Save the output of a command to a file:

command > /path/to/file.txt

Some of those were pretty basic, but useful things. Others I just found out about a few days ago. Hope these were useful.

Cheers!

Share this post


Link to post
Share on other sites
Rob2687    72

Some nice tips there. I never figured out the Tab auto complete until a few months ago.

More wireless tools

-Display Wireless Events generated by drivers and setting changes.

iwevent

-Get more detailed wireless information from a wireless interface

Use this to show available access points plus tons of other info about your wireless connection.

iwlist

Share this post


Link to post
Share on other sites
Barney T.    2,334

Share this post


Link to post
Share on other sites
Pox    0

Have Fun:

<snip>

but yeah, seriously, pipe everything through cowsay.

emerge cowsay or apt-get cowsay or whatever
...
echo LOLOLOL | cowsay

Oh, and the easy find:

locate haxburger.so.0

and GET VI. it's FAST.

Edited by barneyt

Share this post


Link to post
Share on other sites
mohit parkash    0

thanks such a gr8 and nice information keep posting man.. :D

Share this post


Link to post
Share on other sites
phate    5

Anyone feel like posting some fedora easter-eggs here too :)

Share this post


Link to post
Share on other sites
MrA    6

Given some command (i.e. grep), you what to find the location of the executable:

which grep

Find out what filesystem drivers are loaded:

cat /proc/filesystems

Clear the screen:

Ctrl-L

Clear the line:

Ctrl-U

Logout/close the terminal window:

Ctrl-D

And BTW, the syntax you posted for tail is the old style and you shouldn't use it (it's deprecated). Use:

tail -n number_of_lines

Share this post


Link to post
Share on other sites
Alex Shenoy    0

Not trying to be rude, but could we change the title of the thread to something closer to what it really is. Like Useful Linux Tips, or something like that. I thought this thread was like a thread with hacks or scripts and stuff. Which I thought would be a useful thread for the hacker in all of us.

--Alex

Share this post


Link to post
Share on other sites
Barney T.    2,334
Not trying to be rude, but could we change the title of the thread to something closer to what it really is. Like Useful Linux Tips, or something like that. I thought this thread was like a thread with hacks or scripts and stuff. Which I thought would be a useful thread for the hacker in all of us.

--Alex

Thanks for the input, but I think that the title is ok the way it is......... :yes:

Barney

Share this post


Link to post
Share on other sites
rockwolf    0

This is a really neat collection.

Share this post


Link to post
Share on other sites
markjensen    98

Silly one to calculate pi to 2000 (or whatever else you pick) places:

echo "scale=2000;4*a(1)" | bc -l

"scale" sets the number of decimal places.

"4*a(1)" is 4 times the arctangent of 1.

"bc" is the bash calculator, and given the "-l" switch, it loads in more advanced math libraries.

and "echo", of course, is used to pass the math into bc.

Share this post


Link to post
Share on other sites
MrA    6
Silly one to calculate pi to 2000 (or whatever else you pick) places:

echo "scale=2000;4*a(1)" | bc -l

"scale" sets the number of decimal places.

"4*a(1)" is 4 times the arctangent of 1.

"bc" is the bash calculator, and given the "-l" switch, it loads in more advanced math libraries.

and "echo", of course, is used to pass the math into bc.

On the topic of silly (and obscure), here's my favorite command line:

for DVDs in Linux screw the MPAA and; do dig $DVDs.z.zoy.org @ns1.or.com; done | \
  perl -ne 's/\.//g; print pack("H224",$1) if(/^x([^z]*)/)' | gunzip

Share this post


Link to post
Share on other sites
bibutteryboy    0
who really needs a graphical interface when you can get a million times more info and do a million times more with a good ol shell?

Moms and Dads. Young kids still in school. Your Grandparents. The guy from accounting. Anyone I've missed?

Share this post


Link to post
Share on other sites
devilotX    11

the most useful thing I've found is editing /etc/bash.bashrc and adding a bunch of aliases, then editing /etc/motd to list those aliases and other commands when someone logs in via SSH.

It is via those tricks that I've managed to build a Call Of Duty 2 private server for my uncle, and now via putty he can launch his COD2 server (an old P3 733 with 512 that is hidden behind a desk with just power and network running to it) for him and his friends to play on.

bash.bashrc and motd have helped me out immensely.

also, install htop, more interactive then top, and more useful I think.

Share this post


Link to post
Share on other sites
Nicholas-c    37

move around folders in *unix

CD /folder/folder/

Edit Grub boot loader

sudo gedit /boot/etc/grub.conf

Extracting .tar.gz

tar -zxvf file.tar.gz

Add a user

adduser username

Delete user

userdel username

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.