Reply to topic  [ 5 posts ] 
FAQ: Linux and the Terminal/Konsole 
Author Message
I haven't seen my friends in so long
User avatar

Joined: Tue May 05, 2009 3:29 pm
Posts: 7173
Reply with quote
Ever been frustrated using the Linux terminal? Ever found an online solution to your problem, which uses terms such as "run the program" or "change directory" etc, without giving you a clue about how to do it? Well this guide is for you. I (and hopefully gavomatic, Edd and the other Linux users of this forum) will add terms to this FAQ and describe how to do use the terminal.

How to change directory: "cd" command

Code:
cd /home/username/Documents


Will take you to your Documents folder, where "username" is the user name you use to login e.g. dave 1234

How to run a program: "./" command

Navigate to the folder (using the cd command) which contains the file you wish to run. Then, once you're in the folder type:

Code:
./filename


How to make a downloaded file executable, using the "sudo" and "chmod +x" commands. Firstly navigate to the folder which contains the file you wish to execute and then type:

Code:
sudo chmod +x randomfilename101


and then this if you wish to run it:

Code:
./randomfilename101


If your system is based on KDE instead of Gnome then instead you can use the "kdesu" command instead of "sudo".

That's all for now folks, more to come soon :).

_________________
timark_uk wrote:
That's your problem. You need Linux. That'll fix all your problems.
Mark


Sat May 23, 2009 11:23 am
Profile
Has a life
User avatar

Joined: Fri Apr 24, 2009 12:34 pm
Posts: 98
Location: in The Village
Reply with quote
This is good advice, and I know what you mean. While I didn't actually have these problems since I bought reference books to use while I was getting to grips with Linux, I have read some so-called "n00b friendly" HOW-TOs and thought "If I were a complete n00b, I wouldn't have a clue what they wanted me to do!" :?

_________________
Image


Sat May 23, 2009 3:31 pm
Profile
Doesn't have much of a life
User avatar

Joined: Thu Apr 23, 2009 8:30 pm
Posts: 1757
Location: Cardiff, Wales
Reply with quote
Good idea, got a few more...

Code:
mkdir new
(make new directory – “new” is the name of the directory)
Code:
pwd
(present working directory – where am I in the directory structure)
Code:
cp {file} {file2}
(copy file, replace file and brackets with actual file name, no brackets)
Code:
cp text.txt ~/Directoryofchoice/text.txt
(copy to another directory)
Code:
mv text.txt ~/Directoryofchoice/text.txt
(move to another directory)
Code:
ls Directory
(that’s a lower case L by the way – tells you what is in the chosen directory)
Code:
ls  -X
(tells you what is in the current directory – X sorts the return by type)
Code:
locate text
(will find “text” in a file name)
Code:
locate text -i
(as before but case insensitive)
Code:
locate -n 5 text
(as before but limits the number of returns, in this case 5)
Code:
grep stuff text.txt
(searches for the word “stuff” in text.txt)
Code:
grep -i stuff text.txt
(as before but ignoring case)
Code:
grep stuff *
(searches pretty much everything for “stuff”)
Code:
head text.txt
(gives you the first 10 lines of the file text.txt)
Code:
tail text.txt
(gives you the last 10) both can be used with -n 5 to choose the number of lines
Code:
cat text.txt
(displays the whole file contents)
Code:
zip file.zip text.doc
(compresses and archives text.doc into a zip file called file.zip)
Code:
zip -e file.zip text.doc
(as above but with password protection)
Code:
unzip file.zip
(unzip’s the archive called file.zip)
Code:
top
gives you a list of the currently running programs

_________________
G.


Sat May 23, 2009 5:25 pm
Profile WWW
I haven't seen my friends in so long
User avatar

Joined: Thu Apr 23, 2009 6:36 pm
Posts: 5150
Location: /dev/tty0
Reply with quote
If you want to get back home (I.e. where your documents, pictures, etc are) then you have four choices:
Code:
cd /home/username
cd
cd ~/
cd $HOME


If you want to look at the bottom of a file `tail` can be used as Gav suggested. However, if you want to look at the bottom of a log file or something as it changes, use this:
Code:
tail -f <filename>

This will update the output as stuff gets amended to the file.

If you want to make a folder the as Gav said, `mkdir` is fine, however this won't work if you want to make the folder "/tmp/myfolder1/mydir2/stuff/" and myfolder1 and mydir2 aren't already there...So you can use the following:
Code:
mkdir -p /tmp/myfolder1/mydir2/stuff/

It's also safe to use if folders already exist as they won't get overwritten.

If you know a command name, but want to know more about it and you don't have access to the internet there and then, use the inbuilt manuals with the `man` command...
Code:
man <command>


Sun May 24, 2009 4:29 pm
Profile WWW
I haven't seen my friends in so long
User avatar

Joined: Thu Apr 23, 2009 6:36 pm
Posts: 5150
Location: /dev/tty0
Reply with quote
Really cool thing I just found out...
If you want to read a file you can use the cat command like so:
Code:
cat myfile


If you have something like a file full of code, and you want line numbers, you can also use cat with "-n":
Code:
bl222517@estale:~$ cat -n /tmp/test
     1   my first line
     2   line 2
     3   a third
     4   here's a fourth
     5   bah bah!  Fifth
     6   Random text here
     7   
     8   that was an empty line ^^
     9   ok, over and out!


Mon Jun 01, 2009 10:11 am
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 5 posts ] 

Who is online

Users browsing this forum: No registered users and 17 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group
Designed by ST Software.