LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Debian
User Name
Password
Debian This forum is for the discussion of Debian Linux.

Notices


Reply
  Search this Thread
Old 10-20-2005, 10:32 AM   #1
beeblequix
Member
 
Registered: Oct 2005
Location: Tierra Firma, Earth
Distribution: Debian of course...
Posts: 198

Rep: Reputation: 30
useful commands. your input welcomed.


Here's a cheatsheet for various useful console commands. Others have requested it but any answer typically is a link to another site. Feel free to add to it.

changing users from the console
su root -- changes from current user to 'root'. If you're really lazy just type 'su' with nothing else and it defaults to 'root'.

su beeblequix -- changes from current user to 'beeblequix', the super-duper-user. lol.
--does not mean 'super user'
--does mean 'switch user'
su - root --will make it a new login shell, starting a new shell with those new credentials (thx Wells)


how to use a file ending with '.run'
sh xxxxxx.run -- executes a .run file; analogous to the .exe files in Windows only we have to indicate it to be a shell script with 'sh'
./ xxxxxx.run -- same (thx Zak317)
xxxxx -- IF the executable bit is set just type the file (thx jlightner)
From jlightner:
a) Executables in Linux do NOT require extensions. You can call a command:
billybob.run
billybob
billybob.exe
billybob.whythehelldoihaveanextension
billbybob.sh
(.sh by the way is the one most folks use when creating their own shell scripts IF they give it an extension.)
chmod 755 filename -- grants rwx permissions of filename to the owner, and read/execute to group and those not in the group. Useful for ensuring only the owner can alter a file but still let group and those outside the group use the file
chmod 777 filename -- grants read, write and execute permissions to a file for everyone (owner, group, everyone else)
-- root still 0WNS (aka PWNZ) everything....

some hardware listing commands
lspci -X -- lists pci info in X-friendly way (ex. PCI:2:0:0). If you just use 'lspci' it comes out in hex.
lsmod -- useful to see whether your agpgart is running

converting from one package type to debian friendly one
alien -d somecrappyredhatfile.rpm -- converts a .rpm to a .deb file
-- must have alien installed

getting information on a command
man somecommandIwishtoknowmoreabout -- gives you the War & Peace documentation for stated command
info somecommandIwishtoknowmoreabout -- gives you the *edited: War & Peace PLUS Deepthoughts & Insights Volume* on the command. (sometimes info not available) (thx jlightner)
command --help -- the pamphlet on 'command'

manipulating files, navigating around
ls -l -- long listing
ls -l|less -- (that line is a pipe) passes output of ls into 'less'. this allows you to move back & forth in the listing if it scrolls out of view while in a non-X-ical environment (regular command interface)
ls -lrat -- long list of all in reverse order by time (effectively puts the newest files on the bottom)
ls -lat -- long list of all by time (puts the oldest files on the bottom)
cp XF86Config-4 XF86Config-4.backup.before.installing.new.ATI.drivers -- backs up a file from, well, the short one to the long one. Yes, judging from the name of my backup there is a story to tell
mkdir newdirectory -- makes a new directory beneath current one
mv thisfile.file newdirectory -- moves thisfile.file into our new directory
mv thisfile.file ./newdirectory/. -- same thing but more typing
cd newdirectory -- changes directory into the new one
cd .. -- moves up one level
cd ../.. -- moves up two levels
cd -- changes back to /home/youruser directory
cd /home/youruser -- same thing but more typing
rmdir newdirectory -- removes/deletes 'newdirectory'
rm deletethis.txt -- removes/deletes file deletethis.txt
rm -r -- recursive remove. Careful.
rm -rf -- to force and recursively remove a directory and its content (thx Zak317)

Tarballs -- I have a number of files to archive/extract from archive/view the archive:
tar -czvf balloftar.tar file1 file2 -- create a file 'balloftar.tar' from file1 and file2, funnel thru gzip, and do it all verbosely
tar -xzf balloftar.tgz -- extract and send through gunzip the file "balloftar.tgz"
tar -tvf whatisinside.tar -- takes a peek inside the file 'whatisinside.tar' so that you can view the contents of the tarball without having to extract it
-- useful for packaging and archiving a "grundle o' files".
-- also a good way to prepare for ftp these same "grundle o' files".

what's running and how can I stop them
top -- gives a running system display of everything. Uses a bunch of resources though, so unless your system has nothing else to do use it conservatively.
free -- lists your available memory including pagefile (aka swapfile)
df -- display filesystem. Good to keep track of which directories are hogging up all your diskspace.
df -a -- display all filesystems
df -ha -- in HUMAN READABLE format in 1024 #'s
df -Ha -- same but in 1000's
ps -ef -- lists all running processes. Useful to find process id (pid).
ps -ef|grep armyops -- scans all running processes for some dumb process(es) containing the string 'armyops' (that's America's Army for those of you in Rio Linda...)
kill nnnnn -- kills a process with pid of nnnnn
kill -2 aaaa bbbb cccc dddd -- gently and with compassion kills four processes with pids aaaa, bbbb, cccc, dddd
kill -9 xxxx yyyy -- like Jason-the-13th it just takes these suckers out (xxxx yyyy)

which groups does user X belong to
groups -- will list a number of groups the user of that session belongs to. Example:
[TEST]beeblequix@somedomain:/home/beeblequix> groups
db2iadm1 uucp dialout audio video
This is helpful to know that user beeblequix can play audio files with XMMS because he belongs to the audio group.

what are the contents of a file, shell script, etc.
vi filename.txt -- lets you use the archaic-looking but easy-to-use-once-you-know-it vi editor.
----- g = goto beginning of document
----- G = goto end of document
----- u = undo changes (good to know)
----- i = insert mode
----- dd = delete a line
----- : = command line that you can___
________ write the changes to file with 'w'
________ quit with 'q' or
________ quit-right-now-without-saving with 'q!'
less filename.txt -- uses less cpu & memory than vi; if you want to read a file but don't want to F something up use 'less'
file beeblequix.log -- describes the type of file, in this case ASCII text.
-- (VERY handy if you are not sure whether a file is a proper executable or not, particularly if you are dealing with win32 executables, or in my case with three different architectures -- thx Wells)
From this forum --
-- http://www.linuxquestions.org/questi...ght=cheatsheet
-- see this d00d's 'one page linux manual' (a .pdf). good stuff.
http://homepage.powerup.com.au/~squadron/

how to make my ATI card support 3d in debian
*added 10/21/2005* I actually DID make my Radeon work under Debian...here's the thread:
http://www.linuxquestions.org/questi...hreadid=375259

I'm going to digest this link and post again with specifics to debian.
http://www.alexandern.com/3D_ATI_RADEON_on_Linux.html

Last edited by beeblequix; 10-21-2005 at 03:39 PM.
 
Old 10-20-2005, 11:00 AM   #2
Wells
Member
 
Registered: Nov 2004
Location: Florida, USA
Distribution: Debian, Redhat
Posts: 417

Rep: Reputation: 53
For the su command:

Mention that using a hyphen (i.e. "su - root") will make it a login shell, starting a new shell with those new credentials. Quite handy as it keeps things a bit more seperated.


For contents of a file:

file: Tells you what kind of file you are listing. This can become VERY handy if you are not sure whether a file is a proper executable or not, particularly if you are dealing with win32 executables, or in my case with three different architectures.

strings: Not quite as useful for the casual user, but still somewhat handy for pulling out things from binaries that may be useful.


File Manipulation:

rm: Remove a file. There are numerous switches involved with this command that allow for directories, recursiveness, etc.


File Contents:

It would be helpful if you mentioned that you can simply look at the contents of a file using cat, more, or less. This avoids having to use the somewhat obscure commands of vi.

It would also be handy if some other editors were mentioned such as joe and gedit, or my personal favorite, emacs.
 
Old 10-20-2005, 11:04 AM   #3
zak317
Member
 
Registered: Oct 2005
Location: 500$/monthly
Distribution: Mandriva 2006
Posts: 56

Rep: Reputation: 15
changing users from the console
Don't forget to put a minus between su and root to not only change user but change the environment too. This is necessary when you have different PATH or locale definitions between users.

how to use a file ending with '.run'
or simply ./xxxxx.run

some hardware listing commands
Option -X doesn't exist on my Mandriva box... However, most of the time, you need more info so the option -v is useful.
You should also add dmesg which is the command I use most....

manipulating files, navigating around
Personally, I prefer ls -l | more because the text stays in the terminal. The grep subcommand is also ery useful to find something specifically.
Did you forget the rm command? rm -fr to force and recursively remove a directory and its content.

what's running and how can I stop them
Adding to the free command, I should add the df command which gives you a more user friendly idea of disk free space.


Good work!
 
Old 10-20-2005, 11:10 AM   #4
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
Blog Entries: 15

Rep: Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669
1) Your comment about .run has a couple of issues:
a) Executables in Linux do NOT require extensions. You can call a command:
billybob.run
billybob
billybob.exe
billybob.whythehelldoihaveanextension
billbybob.sh
(.sh by the way is the one most folks use when creating their own shell scripts IF they give it an extension.)

b) You do NOT have to do "sh <command>.run". If the command has the execute bit turned on for the approriate level (onwer, group, world - see chmod command) just typing the command itself will execute it. You only need "sh" first if you didn't make it executable.

2) hanks for the info on alien - didn't know about that so will check it out.

3) Comments on info and man are not quite correct and slightly reversed. For SOME commands you will have both a man page and info doc. If you do the latter will usually contain MORE information so is not "cliff notes". If you ONLY have a man page the info command actually shows you the man page so it can be used in either case.

4) Your kill stuff should show progressive kill: kill, kill -1, kill -15 and finally kill -9 if all else fails. I've never used kill -2 to stop processes - this is a sigint (do "man 7 signal" for details of the various kill signals.)
 
Old 10-20-2005, 11:32 AM   #5
beeblequix
Member
 
Registered: Oct 2005
Location: Tierra Firma, Earth
Distribution: Debian of course...
Posts: 198

Original Poster
Rep: Reputation: 30
thx gents. I'm still somewhat a n00B.
 
Old 10-20-2005, 11:36 AM   #6
Wells
Member
 
Registered: Nov 2004
Location: Florida, USA
Distribution: Debian, Redhat
Posts: 417

Rep: Reputation: 53
Quote:
Originally posted by zak317

Did you forget the rm command? rm -fr to force and recursively remove a directory and its content.
Be very careful with this. It is irrevocable and quite dangerous, which is why I didn't mention this particular combination of switches in the first place.
Quote:

how to use a file ending with '.run'
or simply ./xxxxx.run
This works....sometimes. It depends on whether the script was written correctly. Sometimes it hasn't been, and doesn't define what shell to use when running the shell script in the header lines. In this case, using "sh xxxxx.run" will work. Also, it was mentioned that simply typing "xxxxx.run" will work, but this is not the case unless the file is marked as being executable in the first place and you have the current path listed in the $PATH environment variable.

Concerning the $PATH environment variable, it is considered to be bad practice to put "." (current directory) into your PATH variable as that can lead to inadvertant execution of programs that you do not want to run. For root, this is considered to be verboten.

As for environment variables in general, some commands that help with that:

Bash Shell:

export: sets or displays the environment variables
set: Same as above, but a different display.

C-Shell: (csh, tcsh, etc.)

setenv: Same as the bash shell's export. Slightly different methodology for actually setting a variable though. See the manpage.
 
Old 10-20-2005, 12:14 PM   #7
zak317
Member
 
Registered: Oct 2005
Location: 500$/monthly
Distribution: Mandriva 2006
Posts: 56

Rep: Reputation: 15
Thnx Wells.

This one is maybe for lets say "advanced newbies".....

Quote:
Bash Shell:

export: sets or displays the environment variables
set: Same as above, but a different display.

C-Shell: (csh, tcsh, etc.)

setenv: Same as the bash shell's export. Slightly different methodology for actually setting a variable though. See the manpage.
 
Old 10-20-2005, 01:28 PM   #8
Wells
Member
 
Registered: Nov 2004
Location: Florida, USA
Distribution: Debian, Redhat
Posts: 417

Rep: Reputation: 53
Quote:
Originally posted by zak317
Thnx Wells.

This one is maybe for lets say "advanced newbies".....
Well...yes and no. If a user is trying to get a software package installed, I know of a number of different software packages that rely heavily on setting different environment variables. Knowing what shell you are using is also quite useful, even as a user, since commands and command syntax can change between shells.
 
Old 10-20-2005, 01:32 PM   #9
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
Blog Entries: 15

Rep: Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669
Talking

Advanced newbies - lets coin a new term: ADVandced Users Ready for Business (ADVURBS)

I'm sure someone will want to MODIFY that.
 
Old 10-20-2005, 01:35 PM   #10
Wells
Member
 
Registered: Nov 2004
Location: Florida, USA
Distribution: Debian, Redhat
Posts: 417

Rep: Reputation: 53
Quote:
Originally posted by jlightner
Advanced newbies - lets coin a new term: ADVandced Users Ready for Business (ADVURBS)

I'm sure someone will want to MODIFY that.
Perhaps....can we get a definition please?
 
Old 10-20-2005, 02:19 PM   #11
zak317
Member
 
Registered: Oct 2005
Location: 500$/monthly
Distribution: Mandriva 2006
Posts: 56

Rep: Reputation: 15
Quote:
Advanced newbies - lets coin a new term: ADVandced Users Ready for Business (ADVURBS)
I love it! Maybe we can submit it to the Great Master and Intergalactic Emperor of the Acronyms (GMIEA) better known as IBM!!

Sorry, I'm getting out of hand.....

 
Old 10-20-2005, 02:25 PM   #12
beeblequix
Member
 
Registered: Oct 2005
Location: Tierra Firma, Earth
Distribution: Debian of course...
Posts: 198

Original Poster
Rep: Reputation: 30
you guys are funny...lol
 
Old 10-20-2005, 02:31 PM   #13
dive
Senior Member
 
Registered: Aug 2003
Location: UK
Distribution: Slackware
Posts: 3,467

Rep: Reputation: Disabled
Small point about 'su - root' is that you only need 'su -' to switch to root.

Best thing about '-' is that it preserves the path whereas just 'su' loses the path variable.
 
Old 10-20-2005, 03:03 PM   #14
Wells
Member
 
Registered: Nov 2004
Location: Florida, USA
Distribution: Debian, Redhat
Posts: 417

Rep: Reputation: 53
Quote:
Originally posted by dive

Best thing about '-' is that it preserves the path whereas just 'su' loses the path variable.
Actually, but losing the hyphen, you don't truly lose the path variable. What happens is that you keep the path variable you had before instead of generating a new one via a new login shell.

This can be good or bad, depending on the situation. In my line of work, it is typically bad as I am very often using root to login to other people's accounts for test purposes, and I want to be in their account as if I were them. If I had root's path instead of theirs, I don't know whether or not a software package is goign to work for them.
 
Old 10-21-2005, 11:45 AM   #15
beeblequix
Member
 
Registered: Oct 2005
Location: Tierra Firma, Earth
Distribution: Debian of course...
Posts: 198

Original Poster
Rep: Reputation: 30
added one for tarballs
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Finger-tip Fix Package [thoughts and ideas welcomed!] piete Slackware 3 11-06-2005 08:06 PM
Ctrl+Shift Unicode input gone, after installing Japanese Input Methodes polemon Linux - Newbie 1 09-20-2005 05:17 PM
sugestions welcomed Cooler Arch 10 07-19-2004 04:41 AM
Sendmail: timeout waiting for input from local during Draining Input andrewstr Linux - Software 0 07-14-2004 01:43 PM
Login and password program for linux from scrach, suggestion's welcomed. Tarts Programming 5 08-03-2003 07:40 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Debian

All times are GMT -5. The time now is 06:00 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration