x404.co.uk
http://www.x404.co.uk/forum/

FAQ: Linux and the Terminal/Konsole
http://www.x404.co.uk/forum/viewtopic.php?f=4&t=767
Page 1 of 1

Author:  Linux_User [ Sat May 23, 2009 11:23 am ]
Post subject:  FAQ: Linux and the Terminal/Konsole

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 :).

Author:  stu_1701 [ Sat May 23, 2009 3:31 pm ]
Post subject:  Re: FAQ: Linux and the Terminal/Konsole

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!" :?

Author:  gavomatic57 [ Sat May 23, 2009 5:25 pm ]
Post subject:  Re: FAQ: Linux and the Terminal/Konsole

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

Author:  forquare1 [ Sun May 24, 2009 4:29 pm ]
Post subject:  Re: FAQ: Linux and the Terminal/Konsole

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>

Author:  forquare1 [ Mon Jun 01, 2009 10:11 am ]
Post subject:  Re: FAQ: Linux and the Terminal/Konsole

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!

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/