Stop Microsoft

Operating Systems => Linux and UNIX => Topic started by: H_TeXMeX_H on 2 May 2006, 22:47

Title: Possibly useful commands
Post by: H_TeXMeX_H on 2 May 2006, 22:47
I've had some trouble doing specific things on Linux in the past because I didn't know some rather important commands that everyone should know. Here are a few of them (I'll list more when I remember them):

Code: [Select]
Ctrl Alt F1 this logs you out bringing you to login: prompt, similar to Ctrl Alt Delete in Window$, but more useful. Do this when a program fails to respond and you have no way of reaching a terminal. It removes the need for hard reset.

Code: [Select]
# /sbin/shutdown -r now this restarts the computer from the terminal

Code: [Select]
# /sbin/shutdown -h now this shuts down the computer from the terminal

Code: [Select]
$ ps -U $UID this lists all running processes that you have started

Code: [Select]
$ kill -TERM #### here #### is a process id number, this terminates a process; use in combination with ps -U $UID

Code: [Select]
$ cat file1 file2 file3 ... fileN > concatenatedfile the easiest way to join files.

Code: [Select]
$ rpm2cpio name.rpm | cpio -id --quiet extracts an rpm

Besides these there are things like cd (change directory), ls (list contents of directory), find -type f (find all files in a directory) find -type d (all directories in a directory), ln (make symbolic links), rm (remove files) rm -r (remove directories), grep (find lines in a file), cp (copy files), mv (move or rename files), chmod (change permissions), chown (change owner), mkdir (make a directory) ...

ok well, that's more involved I suppose, but I can tell you it's real useful when GUI fails :D

Here's a nice guide to bash (you don't have to learn shell scripting, just pick things that may be of use, and if you want to, learning bash is not too hard either)

http://www.linuxcommand.org/learning_the_shell.php (http://www.linuxcommand.org/learning_the_shell.php)

and burning CDs and DVDs from the terminal may come in handy too:

http://yolinux.com/TUTORIALS/LinuxTutorialCDBurn.html
Title: Holy crap
Post by: toadlife on 3 May 2006, 04:37
Wow. You didn't know any of those?

:eek:
Title: Re: Possibly useful commands
Post by: Pathos on 3 May 2006, 05:05
err...

when I first really started getting into linux I went through every file in /bin and /usr/bin with --help and man to work out what they did. I forgot most but learnt all the ones I would need.

It was only Tomsrtbt and DSL but it had all the important ones.
Title: Re: Holy crap
Post by: H_TeXMeX_H on 3 May 2006, 18:23
Quote from: toadlife
Wow. You didn't know any of those?

:eek:

Well ... no ... It was kinda hard to find them too, mostly by chance. Besides, the documentation I've found isn't too clear anyway. Oh, I forgot to tell you, I hate reading manuals. And where would you find Ctrl Alt F1 ? I found it while trying to install the non-free nvidia drivers manually.
Title: Re: Holy crap
Post by: piratePenguin on 3 May 2006, 19:07
Quote from: H_TeXMeX_H
Well ... no ... It was kinda hard to find them too, mostly by chance. Besides, the documentation I've found isn't too clear anyway. Oh, I forgot to tell you, I hate reading manuals. And where would you find Ctrl Alt F1 ? I found it while trying to install the non-free nvidia drivers manually.
You would find it by understanding virtual terminals and the way X starts ;) (not something I'd expect people to know)

I was reading books bout GNU/Linux and the different commands before I ever installed it. Because I heard it's so hard, I thought I would need it. As it turns out, it's not that hard, but I still need it, because it makes life 100 times easier.

I don't even use a file manager anymore. What a waste of time :P
Title: Re: Possibly useful commands
Post by: adiment on 4 May 2006, 00:15
even I know those ;) and been using Linux for a few weeks, not that new to it though; tried it out for a few months 2 years ago.
Title: Re: Possibly useful commands
Post by: H_TeXMeX_H on 4 May 2006, 00:58
is there a single manual where they can be found ? or a few ?
Title: Re: Possibly useful commands
Post by: Pathos on 4 May 2006, 02:56
usually I have only accidentally bumped into webpages with lists of useful comands/keystrokes.

http://www.google.co.nz/search?q=useful+linux+commands

we just assumed that running fedora core and have almost 900 posts you would be fairly familiar with all of them.
Title: Re: Possibly useful commands
Post by: H_TeXMeX_H on 4 May 2006, 03:17
Well ... I am now ... but not when I started using Linux. I've learned to program with shell scripts, so I now know pretty much all of them, but it wasn't easy to find them all. I got lucky with shell scripts, I found a web site that hosted a whole book on it ... the web site was taken off, but luckily I saved it as HTML just in case something like that would happen.

Hmmm ... this site looks like it has a ton of them:

http://www.er.uqam.ca/nobel/r10735/unixcomm.html
Title: Re: Possibly useful commands
Post by: Pathos on 4 May 2006, 06:52
ah you gave me and toadlife the impression that you had just discovered them :D
Title: Re: Holy crap
Post by: toadlife on 4 May 2006, 07:15
Quote from: H_TeXMeX_H
Well ... no ... It was kinda hard to find them too, mostly by chance. Besides, the documentation I've found isn't too clear anyway. Oh, I forgot to tell you, I hate reading manuals. And where would you find Ctrl Alt F1 ? I found it while trying to install the non-free nvidia drivers manually.

Well I guess this just shows how out of touch I am with current linux distros.  IN BSD, you don't survive very long without knowing most of those commands.

When you have to set up your X with the old-syle Xorgconfig program and then tweak it manualy afterward and then set up your .xinitrc file by hand just to get your desktop manager to load, you tend to pick up these things quickly.
Title: Re: Possibly useful commands
Post by: H_TeXMeX_H on 20 May 2006, 23:09
Advanced Bash-Scripting Guide (http://www.tldp.org/LDP/abs/html/index.html)

useful in Linux administration
Title: Re: Possibly useful commands
Post by: Calum on 21 May 2006, 17:56
Quote
$ cat file1 file2 file3 ... fileN > concatenatedfile
i am probably being really dumb, but shouldn't it be >> rather than > ?

i am under the impression that > wipes the existing contents of the outfile, if it exists, while >> appends the inputs to the outfile. is this wrong?
Title: Re: Possibly useful commands
Post by: piratePenguin on 21 May 2006, 18:08
Quote from: Calum
i am probably being really dumb, but shouldn't it be >> rather than > ?
It doesn't need to be >> because 'cat file1 file2...' will concatenate file1 and file 2 to stdout, redirect that to overwrite concatenatedfile with >. You could use >> if you want whatever's already in concatenatedfile to stay.
Quote

i am under the impression that > wipes the existing contents of the outfile, if it exists, while >> appends the inputs to the outfile. is this wrong?
No, correct.
Title: Re: Possibly useful commands
Post by: Aloone_Jonez on 21 May 2006, 18:24
I haven't tried it on UNIX but that's certainly the case for DOS which stole piping from UNIX, so I agree.
Title: Re: Possibly useful commands
Post by: Aloone_Jonez on 21 May 2006, 18:26
I've just tried it now, you're right.

Code: [Select]
alun@cpc2-bedn1-0-0-cust299:~$ echo Hello World >myfile.txt
alun@cpc2-bedn1-0-0-cust299:~$ ls
CD4050BC.pdf  Desktop  dosemu myfile.txt  OperaDownloads  results
alun@cpc2-bedn1-0-0-cust299:~$ cat myfile.txt
Hello World
alun@cpc2-bedn1-0-0-cust299:~$ echo Hello World >myfile.txt
alun@cpc2-bedn1-0-0-cust299:~$ cat myfile.txt
Hello World
alun@cpc2-bedn1-0-0-cust299:~$ echo Hello World >>myfile.txt
alun@cpc2-bedn1-0-0-cust299:~$ cat myfile.txt
Hello World
Hello World
alun@cpc2-bedn1-0-0-cust299:~$