Jump to content

Unix Intro: Difference between revisions

m
Line 63: Line 63:
  nano phonenumbers
  nano phonenumbers


This will open up the nano editor, with a blank file called 'phonenumbers'. Now, just simply type in whatever you want in this file.... To save it you can hold down control and hit 'o' (when I say control-o, that's what I mean), then hit return to confirm the filename 'phonenumbers'. If you want to exit, then you don't have to do a control-o, you can use control-x. It will ask you if you want to save the changes, so you press 'y' and again hit return to confirm the filename. :)
This will open up the nano editor, with a blank file called 'phonenumbers'. Now, just simply type in whatever you want in this file.... To save it you can hold down control and hit 'o' (when I say control-o, that's what I mean), then hit return to confirm the filename 'phonenumbers'. If you want to exit, then you don't have to do a control-o, you can use control-x. It will ask you if you want to save the changes, so you press 'y' and again hit return to confirm the filename.


Some more unix commands:
Some more unix commands:


* who
* who


The command who lists all the users on the system, what pts they're on, the time they logged on and the machine they logged on from.
The command 'who' lists all the users on the system, what pts they're on, the time they logged on and the machine they logged on from.


* ls
* ls


The command ls simply lists all your files in the folder that you are in, One point, there can be 'hidden' files in a folder. Their names begin with a "." They aren't really hidden, it's just that ls won't see them, unless you tell it to look for them by using the command
The command 'ls' simply lists all your files in the folder that you are in, One point, there can be 'hidden' files in a folder. Their names begin with a "." They aren't really hidden, it's just that ls won't see them, unless you tell it to look for them by using the command:


* ls -a
ls -a


This will show ALL files in that folder. Another 'argument' that you can pass ls, is the l option, which gives a detailed listing of the files, and you can specify more than one argument to ls, or any other command for that matter. The command:
This will show ALL files in that folder. Another 'argument' that you can pass ls, is the l option, which gives a detailed listing of the files, and you can specify more than one argument to ls, or any other command for that matter. The command:


* ls -al
ls -al
will give a detailed listing of all files in your current folder, including 'hidden' files:)
 
will give a detailed listing of all files in your current folder, including 'hidden' files.


* cd
* cd
Line 117: Line 117:
* cp
* cp


The command cp is used to copy files around the place. There are two arguments you must pass to cp, the source file(the one you want to copy) and the target file, (the file you want to copy it to). That sounds confusing but it's not really. When you copy a file, you can specify a directory as the target, that way the file will be copied with the same name into that directory. Some examples will show this better:
The command cp is used to copy files around the place. There are two arguments you must pass to cp, the source file (the one you want to copy) and the target file (the file you want to copy it to). That sounds confusing but it's not really. When you copy a file, you can specify a directory as the target, that way the file will be copied with the same name into that directory. Some examples will show this better:


  cp ~/project/intro.txt ~/
  cp ~/project/intro.txt ~/
Line 166: Line 166:
* cat
* cat


This stands for concatenate. This command is really useful, if you have a text file you want to view without going into a text editor, you can simply type, for example
This stands for concatenate. This command is really useful, if you have a text file you want to view without going into a text editor, you can simply type, for example:


  cat ~/hello.txt
  cat ~/hello.txt


Which will simply display the text file on the screen. If the text file is large, even more than a screen, then this can be annoying. This is where the command more comes in. 'Piping' the 'cat hello.txt' into it will cause the page to be displayed on screenful at a time, using return to go down one line at a time, or space to go down one screenful at a time. There is a command called less which does the same, but it wont bring you back to the command line after youve finished viewing the text file until you press 'q'. The command you need to type is
which will simply display the text file on the screen. If the text file is large, even more than a screen, then this can be annoying. This is where the command more comes in. 'Piping' the 'cat hello.txt' into it will cause the page to be displayed on screenful at a time, using return to go down one line at a time, or space to go down one screenful at a time. There is a command called less which does the same, but it wont bring you back to the command line after youve finished viewing the text file until you press 'q'. The command you need to type is


  cat hello.txt | less
  cat hello.txt | less


The '|' is called a pipe, got by holding down shift and \ , and is used for putting the output of one command, in this case, 'cat hello.txt' and putting into the input of another command, in this case, 'less'. There are lots of things you can do with cat, and redirection(using pipes etc..) but I'm not going to go into that here.
The '|' is called a pipe, got usually by holding down shift and \, and is used for putting the output of one command, in this case, 'cat hello.txt' into the input of another command, in this case, 'less'. There are lots of things you can do with cat, and redirection(using pipes etc..) but I'm not going to go into that here.


That's it....
That's it....


There are more unix commands that you can imagine, the ones I have given here are basic ones, with a few basic examples for you to get started. To get more uses for any of the commands or any others, simply type
There are more unix commands that you can imagine, the ones I have given here are basic ones, with a few basic examples for you to get started. To get more uses for any of the commands or any others, simply type:


man command-name
man command-name


to get detailed instructions on that command. The best way to learn unix is to experiment, just be careful when you're going round deleting stuff:) This is just a primer for those of you starting off on unix, but there are numerous tutorials on unix to be found on the web, when I find a good one, I'll stick a link to it here. Have fun:)
to get detailed instructions on that command. The best way to learn Unix is to experiment, just be careful when you're going around deleting stuff. :) This is just a primer for those of you starting off on Unix, but there are numerous tutorials on unix to be found on the web and you can always talk to [[Helpdesk]] if you have a problem or a question.


== Links ==
== Links ==
http://www.ee.surrey.ac.uk/Docs/Unixhelp/TOP_.html.
http://www.ee.surrey.ac.uk/Docs/Unixhelp/TOP_.html.
496

edits