Command Line Basics
From LUG Manipal Wiki
Contents |
Command Line Basics
This page is intended to familiarize newbies with the linux terminal commands. The terminal is the fun part of linux, whether Fedora or Ubuntu or any other. Learn this and you'll enjoy every bit more!
Something about commands
The linux commands are programs written in some language. On my system these are contained in /bin/ .This implies that if you want to "make" a new command, you can give the file excecutable permissions (more on this later) and place it in /bin/ .
Commands also have "tags" that make them more functional. You'll see this as you progress through this page.
man
The one command that you should have on your fingertips is "man".
This command displays the manual page (if available) for other commands and such.
For example, entering man man at the terminal will open the manual for man itself.
Use this as frequently as you can. It is the best way to teach yourself more and more.
In addition to this, most commands have a tag "-h" or "--info" or "--help" which give you a short discription of the command and other available tags.
[Tab] is another tool which is very useful at the terminal. It works like an "auto-complete" feature. A simple example : You have a hundred files name abcsomething. One of them is abcdef. You press abc[Tab]. It shows you all the options (or asks if the number of options is too large). You press abcd[Tab] and the name of that one file will be auto-completed. You can also use it to autocomplete command names.
eg:: ls -h or ls --info
File System Handling
make sure you do "man hier" to know about the hierachy. Press q to exit the manual.
ls : lists the current files and folders in the directory.
ls -a : lists all files/folders in the current directory. Even hidden ones.
ls -h : lists files/folders in human readable form. man ls etc for more :D
cd : change directory
pwd : displays present working directory
cp : copies a file eg : cp a.x b.x : will copy the file "a.x" to "b.x" you can also give full pathnames. More options at man cp
mv : moves a file. same syntax as cp. Also used to rename files. rm : deletes a file.. Careful with this one.. Code of death :: su -[Enter] rm -rf*[Enter]
Important directories..
"." and ".." are two important directories that you should know. "." points to you current working directory while ".." points to the parent directory.
cd .. : will take you to the parent directory.
The "~" directory stands for your home directory.. For example if I need to traverse to my Music directory, I can use
cd ~/Music instead of cd /home/AnkurSinha/Music
Users
su : stands for switch user. Only entering "su" will change your user to root (once you enter the correct password ofcourse)
su - : changes user to root and gives access to and /sbin also. If you give only "su" you will need to access /sbin by entering the path such as /sbin/ndiswrapper
su -c : Only runs one command as root
su USERNAME : changes user at terminal to USERNAME
More will be added as we remember them.. Youll learn more as you use these and the man pages..
