The second session of the Ubuntu Classroom was held just a few days ago. This time the topic was on the basic use of the command line. The Command Line Interface (CLI) or command line, for short, is one of the most powerful tools in Linux, for which it is both famous and notorious. It is fast, exact, and efficient. But like anything else, it needs a bit of patience and effort to master. But the rewards and benefits are definitely worth it. Of course, the path of the command line may not be for everyone, but it still pays to know your basics.
Summary: Only the very basic commands were covered in both classes, although a few intermediate tips and tricks were also introduced. The first class focused more on the practical applications of the command line, explaining what the basic commands do and how to use aliases, piping, and redirection. The second class dealt more with the concepts of files and directories, and how to use commands to navigate through and manipulate them.
I just combined both transcripts under one post, since they were shorter compared to the first class. I placed a Review of this class and a Summary of Commands Used at the bottom.
- Take 1: August 19, 2006 18:00 UTC – jrib
- Take 2: August 20, 2006 10:00 UTC – ompaul
- Review and Summary of Commands Used
Note: This is the edited and formatted text of my IRC log of the Ubuntu Classroom session held last August 19, 2006 18:00 UTC and August 20, 2006 10:00 UTC on the topic “Command Line Basics”. I have only edited the text in order to present it in an easily readable format. The contents are exactly the same (except in some instances where a small portion had to be relocated in order to place it in the proper context). The contents of the text are not mine but are just the output of the IRC client’s logging feature. Thus the contents belong to the instructor who gave them.
Command Line Basics (Take 1)
Aug 19, 2006 18:00 UTC
Instructor: jrib
Hi everyone, welcome to the second class held by the Ubuntu New User’s Network. I’m jrib and I will be teaching today’s class on Basic Command Line usage. Hybrid wasn’t able to join us for this session, but he’ll be teaching the other session tomorrow I believe. Before we start with some basic commands, I am going to assume that everyone is using a terminal emulator like gnome-terminal or konsole running in your GUI. And I’ll also assume you are using the BASH shell, which should be the case unless you have changed it.
Okay, I want to start by introducing some of the more basic commands that you will be using most often when you are using the terminal. So everyone can open up their terminal now. On GNOME this is accomplished by going to Applications > Accessories > Terminal. [Editor’s Note: In KDE, this would be in K Menu > System > Konsole (Terminal Program)]
You should now have a prompt that ends with a ‘$’, followed by a cursor. To run a command, you just type it on that line, and press enter. I’ll usually try to surround commands with single quotes ” to distinguish them from the rest of the text. You shouldn’t type those in your terminal, just what is inside. [Editor’s Note: commands will also be in bold-face for readability]
Our first command is going to tell us where we are now. So everyone can type ‘pwd‘ now. pwd should return something like /home/user_name. ‘pwd‘ tells us that our current working directory is /home/jasonr. This is the directory that you are in now. Sometimes you will want to change your current working directory. That is where the ‘cd‘ command enters the picture. To use ‘cd‘, you’ll have to understand the difference between absolute and relative paths. Absolute paths start at / and build from there. So, for example /home/jasonr/images/ubuntu.jpg is an absolute path. But if I am already in /home/jasonr, then I can refer to that same file as images/ubuntu.jpg. So relative paths, build on the current working directory. Notice that I can ‘cd /‘ to change my working directory to / and /home/jasonr/images/ubuntu.jpg is still the same, but images/ubuntu.jpg would now refer to /images/ubuntu.jpg which doesn’t exist on my system! There are also a few ‘special’ characters you can use: ‘~‘ refers to your home directory which is usually /home/user_name, ‘.‘ refers to your current directory, and ‘..‘ refers to the parent directory, the directory above your current one. Okay, we’ll do some examples on navigating around your system in a bit. Lets say you were working in /, you would do ‘cd /‘ to get there. Then you can run ‘pwd‘ and verify that you are indeed in /. To get back to your home directory, you can type ‘cd ~‘. As a special shortcut you could also do just ‘cd‘ without any arguments by the way. Directories are separated by / in paths as you have seen. Now to the parent directory, you can type ‘cd ..‘. Now try ‘pwd’ and you should see that you are in /home. Also, one last thing that is nice to know is that ‘cd –‘ brings you back to the last directory you were in.
At some point you will also want to know what files are inside the directory you are in now. For that you can use ‘ls‘. Now everyone can type ls and you should see the files in your current directory. ‘ls‘ can also take pathnames as arguments, so you could do for example ‘ls ~‘, ‘ls /‘, and ‘ls ../../etc‘. You can try those now and see the results. I assume you are in your home directory now which is /home/username. In that case, that last one should be list the files in /home/username/../../etc which is the same as /etc.
Now lets introduce how you can create directories and files with the command line. Everyone can do ‘cd‘ now to get back to your home directory. Then to create a new directory you use the ‘mkdir‘ command followed by the pathname to the directory. So everyone can try ‘mkdir ubuntuclassroom‘. This is the same as ‘mkdir ~/ubuntuclassroom‘, ‘mkdir /home/user_name/ubuntuclassroom‘. These are a few of the different ways you could refer to the same place. Does everyone see why? Okay, now lets go into the directory we just created: ‘cd ubuntuclassroom‘. That name is kind of long though, so you may not want to type it all out. Instead you can start to type ‘cd ubuntucl‘ and then press your [Tab] button. As long as there aren’t any similar directories in your home directory, the shell should complete the rest of the name for you and you can press enter (a lot like IRC names in many IRC clients).
Alright, now we can create a few files. We can create blank files using the ‘touch‘ command. And it takes multiple files as arguments. So we can create 5 files name for the letters in the alphabet like so: ‘touch a b c d e‘. And you can type ‘ls‘ now to see that we have 5 new files there. Now lets talk about hidden files really quickly. Any file that begins with a ‘.‘ will be hidden from you, really it is just to keep your screen uncluttered with unimportant files. Let’s make a file called ‘.f’. All of you know, to do this, we would do ‘touch .f‘. Now try ‘ls‘ again. The file isn’t listed! There is a special “switch” for ‘ls‘ though that lets us see hidden files. Try typing ‘ls -a‘ and you should see the .f in the list of files. The -a is called a switch and it is an option for the ls command. You can think of a “switch” to mean the same as an “option”. Many switches have short forms and long forms. Short forms have one dash, ‘–‘, followed by a letter, while long forms are usually two dashes, ‘—‘, followed by a word. ‘ls -a‘ and ‘ls –all‘ are the same. So how did I know I needed -a to show hidden files? This is where man pages enter the picture. The “man” command will display the manual for a command. So you can show the ‘ls‘ manual with ‘man ls‘. You can navigate this page with PageUp and PageDown, or the arrow keys if your prefer to go line by line. A nice thing to know is that you can search for terms by doing: /searchterm [Enter].
Okay, I’ll quickly introduce cp, mv, and rm now. cp is used to copy and the basic syntax is ‘cp file1 file2… directory‘ or just ‘cp file1 file2‘ to copy file1 to file2. Note that when I say file1 I really mean pathname1 since you can do something like ‘cp /usr/bin/cat ~/dog‘. you can do ‘cp a myNewA‘ in our ~/ubuntuclassroom directory for a simple example of copying a single file. At this time, let me mention that linux is case sensitive. This means ‘a’ is not the same as ‘A’. Trying to cp something won’t work. mv is similar to cp except that you are moving instead of copying and rm is our command to “remove” or delete a file. Lets get rid of the b file, with ‘rm b‘. It’s important to note that b doesn’t get thrown in the trash like when you delete in GNOME or KDE. After you hit enter, b is basically gone forever. I think it is smart to use ‘rm -i file‘ instead of just ‘rm file‘. Let’s try deleting c and see what happens: rm -i c. You’ll notice this time that BASH is nice enough to make sure we really mean it.
So what are aliases? Aliases let you give really long commands a shorter name. Some of you may have some set, others may not have any. That’s ok, we’ll learn how to create them. The syntax for creating an alias is just like the alias output looked. Lets all alias rm to rm -i. The command for this would be: alias rm=’rm -i‘. After doing that you can type ‘alias‘ and see that it took effect. Now when you type ‘rm d’ in our ubuntuclassroom folder, it should again prompt you even though you didn’t write rm -i. However, these aliases won’t stay after you close your terminal and open it again (you can test this out now if you want) To make them stay, we have to put them in a special file that bash will read when it starts. This file is ~/.bashrc. We can take a look at it with a command named ‘less‘. less will open things and put them on pages. So ‘less ~/.bashrc‘. You can go down and see all of the things that are going on and if you still have the default one, you will see a section on aliases. That is where you could add your own. If you haven’t seen similar files before, the lines that start with # are usually comments and are ignored by bash. The rest are commands that bash reads. One of the comments you will see is:
# Alias definitions.
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.
And that means that if you prefer, you can just put all of your aliases in ~/.bash_aliases and ~/.bashrc will see that and read them from there. I promised you we would implement an ‘rm -i‘ alias, so now lets all hit the “q” button to get out of less and we will use a terminal text editor called nano to create and implement our ‘rm -i‘ alias. Everyone can do ‘nano ~/.bash_aliases‘. Then type in our command from before: alias rm=’rm -i‘. On the bottom you will see that ^O will write the file, or “save” it. That means press Ctrl-O. And then of course Ctrl-X to exit. Everyone can type ‘cat ~/.bash_aliases‘ now and cat will output the contents of the file right onto the terminal. If all went well you should see that your alias is there. Now you could close your terminal and open it again for the alias to take effect. Or as a shortcut you can tell bash to just run all of the commands inside the ~/.bash_aliases file. The command for that would be: source ~/.bash_aliases. A shortcut for that is: . ~/.bash_aliases. Let me just point out that the default file has the code that makes ~/.bash_aliases work in ~/.bashrc is commented out. I’ll leave it as an exercise for everyone to uncomment the three lines that let your source ~/.bash_aliases. Those look like:
if [ -f ~/.bash_aliases ];
then . ~/.bash_aliases
fi
Ok, now I’ll cover piping and redirection very quickly because it is one of the best features. Lets say you didn’t know what command you used to copy files. The ‘apropos‘ command lets you search a programs description. So lets try ‘apropos copy‘. You probably say a lot of stuff and some of it may have even scrolled off the screen. You can use our pager called ‘less‘ to turn it into pages though, try: ‘apropos copy | less‘. The | symbol lets you take the output from one command and pipe it to the input of another command. This is ‘standard output’ and ‘standard input’. There is also ‘standard error’ where programs like to print errors to (this ends up in your screen just like standard out). But piping only pipes standard out. you could also search the output for a certain word. The command for this is ‘grep‘. So lets try ‘apropos copy | grep file‘. That should narrow down the results a bit more, and if they are still too long we can still do ‘apropos copy | grep file | less‘.
And for the last topic, I’ll show you how to save the output to a file. So lets try ‘apropos copy > ~/howToCopy‘. You’ll notice that there won’t be any output. But try ‘cat ~/howToCopy’ and you’ll see the contents of the file. To append to the bottom of a file you can use >>.
Okay, I think that’s all we have time for today.
Questions and Answers
-
Q. I’m just SSH-ed into my box, is that a problem?
A. As long as you are using bash it should be ok. I just want to make sure you can have a terminal open at the same time as you read what I say - Q. Why can’t you “cd file.jpg” ?
A. You can use cd to change your directory to any other directory. Directories are similar to physical folders with files in them. There is no reason you couldn’t have a directory named “file.jpg” with more files inside of it. But if file.jpg is in fact a jpeg file then you won’t be able to cd to it - Q. Why do we see the files ‘.’ and ‘..’ when we do ls -a?
A. See in every directory the files ‘.’ and ‘..’ will be created. That is how the “special” characters I mentioned earlier ‘.’, and ‘..’ work. ‘.’ is actually a symbolic link to the same directory it is in. And ‘..’ is a symbolic link to the directory above the one it is in. You can think of symbolic links as a kind of link that points to a different place on the filesystem. With that in mind, seeing those can be kind of annoying. And in ‘man ls’, you’ll see that ‘ls -A‘ will ignore ‘.’ and ‘..’. - Q. Some folders have tons of files in them… and when using aterm you don’t get a scroll bar… is there a way of showing the output of ls page by page or something like that?
A. ls | less (see “Piping and Redirection“) - Q. Why are some file’s in my terminal blue? Is this about permissions?
A. ls will use colors to help you distinguish types of file. This is because you actually have ls aliased as ls –color. (see “Aliases“) - Q. Does that mean that if i don’t comment these lines out [in ~/.bashrc], the .bash_aliases file will not be run at login?
A. Right, that code basically says if ~/.bash_aliases exists, then source it. “Source it” means it will read the file and run the commands it find inside. (see “Aliases”) - Q. How do you “ls” only directories? the same question go for listing only files
A. ls -d */ lists only directories with ls. I’ve also seen some tricks with people using ls -F and then grepping for the special character at the end. (see “Basic Commands“) - Q. What can i do with command “alien“?
A. ‘alien‘ is a program that tries to convert rpm’s to deb’s so you can install it in Ubuntu. I’d recommend you try to stay away from using rpm’s though. Try to use an Ubuntu repository, then an Ubuntu deb, and if you still can’t find the program, I would suggest just compiling it - Q. What about scripts ? is it enough to write a bunch of commands in a file ? and then how do i run it ?
A. Any text file may be made executable with “chmod +x file“. But basically you want a shebang line as the first line telling it what to run and you want to make the file executable. shebang’s are things that look like: #!/bin/bash - Q. Is source a bash builtin? There is no man page for it.
A. Yes source is a shell built in. With bash, you can get help on builtins (in the man page of course) or by typing ‘help source‘.
Command Line Basics (Take 2)
Aug 20, 2006 10:00 UTC
Instructor: ompaul
\o/\o/\o/ welcome to #ubuntu-classroom \o/\o/\o/
First off lets open a terminal. So click on application -> accessories -> terminal [Editor’s note: KDE users click on K Menu > System > Konsole]. Okay just to blind you with science (or some such), I want to introduce the concept of a shell. You have in front of you in the default black writing on a white background [Editor’s note: your setup may vary].On the left there is something that looks like this:
ompaul@desktop:~$
This is your username at your machine and it currently indicates you are in your home directory
if you type at that command ‘set | grep SHELL‘, you will see that the first line returned is SHELL=/bin/bash. Okay that indicates what “shell” your “environment” is set to use. This is the program that you use to converse with the kernel. This program provides a programming environment (usually in the form of scripts) to allow a user to interact with the machine and manipulate it. There are two ways it does this: it invokes command within itself or it can invoke commands external to itself. The ones within are referred to as “buildins”.
So the first command I want you to in there now is pwd. This command tells you where you are. pwd is hard to remember but it actually stands for print working directory. Now you may see from time to time things such as ‘ls -al‘ the part after the ls is called an argument. pwd accepts two arguments. The first is –help, which displays help for the program, and the other is –version, which displays the version number. After both of these functions have completed (and providing they complete correctly) the program exists. please run the following ‘pwd –help‘ to demonstrate an argument.
Let us use the command which invokes manuals. This is the ‘man‘ command. Please type ‘man –help‘ in your terminals now. You will notice that a lot of data is on the screen and the scroll bar on the right should indicate that some data has passed by. However we do not always have the luxury of a scroll bar. So now we will have a quick look at how to see more data. So to see the data one screen at a time, you can do this: ‘man –help | more‘. The function of that pipe is to take the output from ‘man –help and then present it to the command more. What more does is it allows output to be viewed one screen at at time. So if you press the down arrow the screen will scroll down one line at a time and if you use the space bar it is one page at a time. However more faces a restriction, a big restriction – it is one way. It only allows you to go down. so we can do “more than more” by using a new command, less. So it is that we can go backwards with less. We can use up and down arrows and page up and page down. This is useful of you have lots of data. So if you do ‘man –help | less‘ you can test this. You can navigate up and down and then to quit you can press ‘q’. The letter ‘q’ is your friend.
Now for some basics. Now lets have some fun. Please type ‘man man‘. On the foot of the screen you will see something like this: Manual page man(1) line 527/551 (END). This indicates what manual page you are looking at before the bracket(1), in this case man, and it also lets you know how big the manual page is the last digit, in this case 551. Although the manual pages are written in a very “tight” style, if you get used to them you will find them good friends to discover options when you try to do something more complex. Now please press ‘q’ and exit that man page.
Firstly let me tell you something of the layout of linux as it will help you understand some of what is there in front of you. When I say layout just now referring to the filesystem. You are currently in what is called your home directory. The prompt is as I showed earlier ‘ompaul@desktop:~$‘, the ~ after the : is short hand for saying /home/your_username/. The word ‘directory’ in English actually means “list”. However to be clear about what a directory is I like to think of the hard drive as a filing cabinet. There are many drawers in the filing cabinet each of the drawers can contain more drawers. To see the list of “primary drawers” we can use the command ‘ls‘ which is short for list. The whole cabinet is called ‘/‘, which we call “slash”. Not forward slash but slash. This \ is “back slash”. There is no forward slash. So let us get a list of the things in ‘/’. ‘ls /‘ Run that command. So you see bin, it is the first directory there. So now please do ls /bin. The colour you see for bin indicates it is a directory. You are now looking at the contents of /bin. You can see some very common every day commands there. ls is there, date, ps (which shows what processes are running on the computer when given certain arguments), tar, touch, sed, and a lot of others. The colour you see for arch and bash and most of the others in there is for an executable file, depending on how your console is set up. Please do this ‘ls -al /bin/bash‘.
-rwxr-xr-x 1 root root 6644-21 23:51 /bin/bash
That is what it replies or something like that. You will notice that the there are several letters on the left hand side of the screen and some dashes. They are the file permissions: r = read from the file | w = write to the file | x = execute (run) the file. You may notice that I say file and also you may remember I referred to “drawers containing drawers”. Well directories have file permissions too. In fact directories are nothing more than fancy files that contain more files and they too have permissions. If you run ‘ls -l / | grep bin‘, you will get back:
drwxr-xr-x 2 root root 47-12 17:5
drwxr-xr-x 2 root root 8192 28-18 23:37 sbin
Now on the extreme left of the permissions you will see the letter ‘d’. This indicates that these files are directories. So now you have two concepts, files and directories”, now you have also a concept of permissions, however not in detail. You will notice if I take the /bin/bash permissions that it starts with a -, then it has the first group of three rwx, then a group with r-x and another group with r-x. Well reading left to right we call these groups Owner Group World (or I have heard it called Everybody). So what does this mean? Well this gets more meaning from the two columns after the number 2, ‘root root’. This is the owner of the file and the group that the file is owned by. root owns the file and also there is a group called root. They are not the same. In some cases like where your username is the group. I will break it out into little blocks.
Please type ‘ls -al /etc/group‘. First off note that it is not executable. Second note that while anyone in the group ‘root‘ [can read it], anyone (everybody/world) can read it. So it is readable by all users on the computer. Now let us look inside that file: ‘less /etc/group‘. First line ‘root:x:0:’. So this is a group. The group has a numerical id. It is seen in the output. Then as you look down the file you will see your username. It will be a member of some of the groups in the machine. On Ubuntu, ‘admin’, for instance, is occupied by users who have “administration powers”. If you press the space bar you will get to the end of the file. You will see the first user created on the machine as a group name, the username with a GID (group id number) of 1000. In a business you might have a group sales and they would all be able to access the files belonging to the group “sales”. Now the reason we went down this road (and whole chapters in books have been written about permissions) was to explain that a file has an owner (as in a user) and a group owner. And these things can be used to grant access to the users on the box or deny them access to a file. This is important because if you can’t run a file, you may be trying to access something that the system will not allow.
So now in your home directories, [all that information in a way that people don’t]
ompaul@desktop:~$ stat Desktop/
File: `Desktop/’
| Size: 4 | Blocks: 8 | IO Block: 4 directory |
| Device: 371d | Inode: 4653 | Links: 7 |
| Access: (drwxr-xr-x) | UID: ( 1 ompaul) | GID: ( 1 ompaul) |
Access: 28-22+0100
Modify: 28-2.+0100
Change: 28-2.+0100
Okay, you will see the file name at the top. I said earlier that directories were files
you will see Desktop/ being called a file. Now for the most mind blowing thing you will ever learn about linux and UNIX based systems (at least in my opinion): EVERYTHING IS A FILE. And I mean that your screen, your keyboard, your mouse, they can be read, written to. Your printer, your USB key, the whole system is a collection of files. You take data and you move it from one place to another. This all goes back to an early design choice and it was very fortunate for us they choose that. What it means is that you can take the output of a file and redirect it to another. You an then add to it subtract and a whole lot of other things. I will demonstrate that next.
First off let us create a file in our home directories. The way to create an empty file is to use the touch command. It is normal to refer to random files as “foo”. Please type ‘touch foo123‘ in your terminal. Now ‘stat‘ it. The inode data there is its actual address on the file system, which contains the info about where the file lives. On the system, as you note, the file is owned by you, it is readable and writable by you, it is readable by the group and anyone on the machine. You remember earlier we used “man –help“, well let us capture that data in the file foo123. So do this ‘man –help > foo123‘. We can now look at the file with stat or we can do it the way most people do it ‘ls -l foo123‘. Right now it looks like “-rw-r–r– 1 ompaul ompaul 2396- 12:45 foo123“. The 2396 is the size of the file. Lets overwrite. But first have a quick look: ‘less foo123‘. Press the space bar until you get to the end, then press q to get out of less. So do this ‘wc foo123‘. Now what do you think your looking at? lets find out what your looking at ‘man wc‘. What does that tell you? “wc – print the number of newlines, words, and bytes in files“. So it tells you the lines that are in the file. Please press q to leave the man page. So we have seen the original stat data of the file. Lets look at that: ‘stat foo123 >> foo123‘. That should be fun. After that type ‘wc foo123‘. Okay so when we type ‘wc foo123‘ we note that the line has a size, then if we do the next part, ‘stat foo123 >> foo123‘, we add the stat info onto the end of the file. So the point here is that the > single redirection pipe takes some “random input” and puts it into the file “in this case foo123”. When we use the >> this APPENDS the additional data to the file. In this case we got it to add on the contents for foo123 to the tail end of the file. You can see this if you now type ‘less foo123‘. Now that is three pipes covered:
- “A | B” take the data from the left (A) and hand to the the program on the right (B) to be processed
- We have also taken random data and put it into a file, usually that is output we want to capture to analyse for later. That is done with the >
- And then we can open an already full file and append data to it. This is the >>
NOTE the > overwrites all previous data.
So now you have:
- ls
- ls -al
- |
- >
- >>
- touch
- man
- and the concept of an argument.
Now to find your way around the file system. You are in your home directory. You can move from there to your desktop. So in the terminal please type ‘cd Desktop‘. You have now moved to the desktop. If you “touch foo1234” here you will create an empty file on your desktop. Please do so and check it exists by minimising your IRC window.
To explain some more about where you are please consider the file system to be like this:
| / | |
| /home/ | |
| /ompaul/ | |
| and /Desktop/ |
The full path is /home/ompaul/Desktop/. Now we also know about /bin/. There are hundreds of directories on the machine and thousands of files (if not millions). Now ‘cd /‘ takes you to the root of the file system. You do not want to be creating things there. In fact you do not have rights to create data in that directory. The place you should create data is in you own directory or some subdirectory below that. Now if you are in the Desktop directory you can create a new directory in that: ‘mkdir myfirstdirectory‘. You can then enter that. ‘cd myfirstdirectory‘. So now you are within that location. Let’s do something. Let’s use the df command which tells us information about the file system layout. But lets make it human friendly output. Do the following ‘df -h‘. Now if you want to compare how much data how much disk space is used over time we can record the disk space used today, so do this: ‘df -h > dfinfoAug26‘. So this gives us humans a file we can relate to. Now if you go to your desktop and click on “myfirstdirectory“, you can find the file we just created in it. Okay lets make a copy of that file into our home directory. In the terminal ‘cp df‘ now hit [Tab] key. See it complete the file name. Now you want to get it into your home directory ‘cp dfinfoAug26 /home/ompaul/.‘ note the dot at the end. I could change its name with this ‘cp dfinfoAug26 /home/ompaul/MyNewName‘ or even do this ‘cp dfinfoAug26 ~/ompaul/.‘, which is the same as the first one.
Have fun! https://help.ubuntu.com/community/BasicCommands see that also.
Review: This was another job well done for the Ubuntu-NUN team! A very interesting and extremely useful topic. Beginners will learn much from this, while users could take the oppurtunity to refresh their memories. The command line is an extremely powerful tool, even in today’s seemingly GUI-centered age. The real challenge is how to make the command line less frightening and more practical to new users.
This class, like the previous one, seemed to be plagued by time issues. My suggestion still remains the same: announce the time for both classes before hand. This is specially important if the two instructors will be covering slightly different materials/topics, like what happened in this instance. As it turns out, the second day was not merely a repeat of the first class, but a supplementary session.
Summary of Commands and Symbols Used:
| Command | Description |
| pwd | Print Working Directory |
| cd | Change Directory |
| ls | LiSt |
| mkdir | MaKe DIRectory |
| touch | touch/make a file |
| man | MANual |
| cp | CoPy |
| mv | MoVe |
| rm | ReMove |
| alias | Make a word/command into an ALIAS of a longer command |
| cat | conCATenate(link/combine) files then display the result |
| more | display output one screen at a time; can only move forward |
| less | display output one screen at a time; can move forward and backward; “you can do more (than more), with LESS |
| nano | launch NANO text editor |
| apropos | search manuals for a program’s description |
| grep | search a file/output for a certain pattern |
| chmod | CHange file’s MODe/permissions |
| help | display HELP information for builtin commands |
| stat | display file STATus |
| wc | Word Count |
| df -h | display disk space usage in human-readable format |
| Symbol | Description |
| / (as in cd /) | root or primary directory |
| ~ | home directory |
| cd – | cd to last directory you were in |
| . | in the same directory |
| .. | parent directory |
| | (pipe) | A | B take the output of command A and present it as the input of command B |
| > | A > B take the output of A and redirect/put it in file B, overwrite previous contents |
| >> | A >> B take the output of A and redirect and append (add) it to the contents of file B |
Really thanks.. I’m an ubuntu user an like to be a professional in it .. This helped me a lot . Thanks again . If you can please mail me about more of terminal works… Thanks again and again !!!
Thanx a lot man….
I couldn’t get touch foo123 to work. kept bringing up this –> touch: cannot touch ‘foo123’: Read-only file system
Where are you trying to type this? The directory/folder where are you trying to do this must be accessible by you. In other words, it should belong (be writeable) to you.
I was following the example given. Not to worry it was due to some issue regarding a bug that came over from some personal documents. Honestly I’m brand new to Linux (having spent about 3 years only using GUI for Jolicloud) terminal operations. I reinstalled Ubuntu last night and now I’m fine. Going to try this section again and see what happens. As far as your comment, a friend of mine who gave me his USB stick to do the install said that exact same thing. Thanks anyway. š I’ll keep you posted, if you like…