PDA

View Full Version : Post your linux tips here!



PompeyBlue
29th March 2006, 10:59 AM
Here's a few things I found that I use all of the time.

1. ctrl-z

Will shell you out of a terminal program, suspend the program, and put you back into the terminal again. Type "bg" to put the program into the background. Type "jobs" to get a list of jobs. Type kill %<job_number> to terminate any of those jobs. Type "fg" to bring the last job in the list back to the foreground (i.e. take it over again)

2. top

Type top to find what the system is spending it's time doing. Type kill <process ID> to kill any of those processes

3. man

type man <command> and get information on any command that you are trying to use

Any others ?

foobar47
29th March 2006, 03:31 PM
4. su -

Ask for root password. Usefull sometimes...

5. vi myfile

Edit myfile

6. tail -f /var/log/somelogs

I open a new terminal and execute this command to show what appends when a service failed or other...

foobar47
29th March 2006, 03:44 PM
7. history

Help me to get old commands... combined with some other command, can remember me old stuff...
history | grep "some part of the command i d'ont remember"
history | grep tail returns all command including tail I previously type...

You can easily reload a command by typing !number
number correspond to the command number

Exemple :
history | grep ldap
1008 vi /etc/ldap.conf
1015 yum install openldap openldap-clients pam nss_ldap
1016 yum install openldap openldap-clients pam nss_ldap
1017 yum install openldap*
1019 rpm -q openldap
1020 rpm -q openldap*
1021 rpm -q openldap-*
1022 rpm -q openldap-c*
1023 yum install nss_ldap
1024 yum install pam nss_ldap
1034 ldapsearch -x "sAMAccountName=toto"
1035 ldapsearch -x "sAMAccountName=jgrofer"
1037 vi /etc/ldap.conf
1038 ldapsearch -x "sAMAccountName=jgrofer"
1040 ldapsearch -x "sAMAccountName=jgrofer"
1041 vi /etc/ldap.conf
1045 ldapsearch -x "sAMAccountName=toto"

If i type !1045 the system relaunch the command ldapsearch -x "sAMAccountName=toto"

fedorange
29th March 2006, 04:55 PM
To enable single click selection of Firefox URL (like in Windows)

Enter "about:config" in URL

Filter on "click"

Change value of "browser.urlbar.clickSelectsAll" to true (double-click or right-click/toggle)

Restart Firefox....

Zigzagcom
29th March 2006, 07:39 PM
Commandline completion and seeing which commands are in your path:

At the cli prompt you can type a letter of the alphabet (lower case), hit the tab key twice, and all commands in your path, starting with that letter, will be displayed.

Try it, your machine will not explode.

Thx for the firefox tip.

PeTzZz
29th March 2006, 08:09 PM
10. If you want to use a path in some command in the commandline that has spaces in it due to folder or filename that contains two or more separate words then you should use that path between ' marks.

For example mkdir '/home/peeter/directory name' makes a directory called directory name in /home/peeter.

EDIT
Yeah! :p

Zigzagcom
29th March 2006, 08:12 PM
Peeter, the directory name will be 'direcory name', unless the cli does auto correct... :D

allyse
29th March 2006, 08:15 PM
ctrl+r (reverse search) cant live without it :D

starkweatherr
29th March 2006, 11:02 PM
man -k {command name} seems to bring up a list of everything similar to the command name you enter.

FI, I entered 'man -k copy' and found out that the file copy command is actually named 'cp'

w5set
30th March 2006, 01:48 AM
Up arrow key in the CLI gives the last command used--2 of them the 2nd from last--etc--etc...

Using a black background with green letters in Konsole (KDE) gives better contrast and makes "stuff" that normally prints white on white when running rkhunter and others really stand out..or red letters really jump out too. And makes the blue (default) directory lettering really hard to see, so change that in prefs.
Konsole is very config-able.

Zigzagcom
30th March 2006, 02:56 AM
One of my all time favorite link to tips:

http://souptonuts.sourceforge.net/how_to_linux_and_open_source.htm

Flounder
30th March 2006, 03:10 AM
BASH shortcuts
ctrl-a to go to the begging of the terminal again.
ctrl-d to logout of terminal (faster than typing logout or exit)
ctrl-c to stop a program

There's more but that's what I use on a regular basis go to www.tldp.org/guides.html for more.

Scytale
30th March 2006, 05:55 AM
I find piping the more command really useful, not sure how many people know about it but if you can use it to break up the input one screen at a time.
cat /var/log/messages |more

lets you scroll through the message log, which is pretty handy. You can even append more to things like ls.

You can add lines to config files by using echo and the redirection operator (>) saves having to fire up a text editor for simple changes.

Zigzagcom
30th March 2006, 06:16 AM
Scytale,

more /var/log/messages
does the same.

foobar47
30th March 2006, 09:48 AM
ctrl + l to clear bash

giulix
30th March 2006, 03:16 PM
Ok, this is the most valuable tip (yet often overlooked) that I've learned over the years: back up your data. Especially when planning a new install (not to mention an upgrade): You got 1 HD only ? Create multiple partitions and back up on those; 1 optical storage ? Do regular backups; multiple disks ? Back each other up; multiple systems ? Back up one onto the other. I've got 3 systems: each one is a backup for the other 2, plus I have all of them backed up on DVDs; non-sensitive data is additionally backed up on Gmail and sensitive data... well, that's backed up, too.

LocutusOfBorg
30th March 2006, 03:24 PM
Ok, this is the most valuable tip (yet often overlooked) that I've learned over the years: back up your data. Especially when planning a new install (not to mention an upgrade): You got 1 HD only ? Create multiple partitions and back up on those; 1 optical storage ? Do regular backups; multiple disks ? Back each other up; multiple systems ? Back up one onto the other. I've got 3 systems: each one is a backup for the other 2, plus I have all of them backed up on DVDs; non-sensitive data is additionally backed up on Gmail and sensitive data... well, that's backed up, too.
... and I thought that I was paranoid! :D

giulix
30th March 2006, 03:35 PM
Oh well, in this line of business either you're lucky enough to have a natural predisposition, or you have to learn the hard way... ;)

PompeyBlue
30th March 2006, 05:24 PM
Thanks for all of the tips folks - there's some top ones there

maximus92
31st March 2006, 07:13 PM
Here's a tip I found out by just messing around. I've been trying to figure out how to make a shortcut to a directory on the desktop. Now, this may be common knowledge, but I searched everywhere, and couldn't find a step by step explaination on how to do it.

Now, I'm at work so this may not be very accurate, and I'll correct as necessary when I get home to my beloved Linux machine. Right click the desktop and choose "Create Launcher..." Next, in the window that pops go to the drop down box and choose "link", then name the shortcut. In the URL box type the directory that you want to point it to. For example, I wanted the shortcut to point to my windows drive, so in that box I typed "/mnt/windows/" without the quotes. Hit finish, or ok, or whatever it is, and ta-da shortcut.

Now I downloaded a nice icon that was made by someone else for the mac, and I converted it to a png file. It's a drive with a Windows XP logo on it. I'll attatch it later.

oldforce
31st March 2006, 07:52 PM
i found this today...
if you installed a newer version of a plugin or a library...
rpms are installed but if software wants to call the old library it quits..

so create a link to new library like and copy it to /usr/lib and rename it with the older library...
all will work...

example;
you installed libtasnl.so.3
but software need lintasnl.so.2

freak
31st March 2006, 07:55 PM
disk space

df -h

Lluisanunez
31st March 2006, 08:20 PM
If in Gnome, install gnome-clipboard-daemon (http://members.chello.nl/h.lai/gnome-clipboard-daemon/) and all selected text will keep in the clipboard, even after you closed the application you copied from

a thing
31st March 2006, 09:01 PM
For human readable filesizes put this in /etc/profile:
alias ls="ls -h"
alias du="du -h"
alias df="df -h"

For coloring files depending on their type, put this in /etc/profile:
alias ls="ls --color=always"

Space a directory uses:
du -s

Great reference for Bash scripting and other Bash things:
http://www.gnu.org/software/bash/manual/bashref.html

Customize your Bash prompt:
http://www.gnu.org/software/bash/manual/bashref#SEC83

Mount USB drives async, it's a lot faster.

Tar has builtin support for multivolume archives. To create them:
tar -cML (size of drive you're using in KB) -f /place/device/is/mounted/(name of archive).tar (files to be archived)

When tar prompts you to prepare for the next device, umount the device you're saving the archive to (and wait until it finishes, don't Ctrl+C it!) and take it out. Take the device to some other computer (perferably not a windows-running one, windows mounts things sync) and copy the part of the archive on the device to the computer's hard drive. Go back to the computer you're backing up, mount the device, go to tar and hit enter. Repeat until tar finishes.

To extract this multivolume archive:
tar -xMf (part 1 of archive) -f (part 2 of archive) and on for the rest of the parts