Linux can be intimidating until you actually start using it. It makes you all cool using different commands on terminal and processing – I personally feel like a hacker or so !
I have tried to compile few linux commands in here. Hope you enjoy it . You can also refer to this book here.
But before that, keep in mind that sudo is used only for providing root permissions. So, if you are not inside / (root) , then you don’t need to add sudo in-front of commands. And I guess, you are familiar with basics like – cd, ls, ls -l, apt-get
Tip – To delete something, which you installed from apt-get install, you can uninstall it using:
sudo apt-get purge <softname>
Remove ( rm ) :
For a file :
rm <filename >
In root : sudo rm <filename>
For a folder:
rmdir <filename > ( To make a directory, you can do : mkdir <foldername>
In root : sudo rm -r <foldername> / sudo rm -rf <foldername>
Copy ( cp ) :
For a file :
cp <filename/ file path> <destination path>
In root : sudo cp <filename/ file path> <destination path>
For a folder:
(sudo ) cp -R <folder name/ folder path> <destination path>
So many times, you must have downloaded tar.gz files, but have no idea what to do with them. In simple words, we can tar is basically winrar/winzip for terminal. It unzips the files containing onto a specified path( or same folder, if not specified ).
Lets do a small tutorial on it – We will install java jdk(we all need it). Download the latest version from here. (download the tar.gz one accepting the agreement).
Now you can extract it in : /usr/local/bin or /usr/bin , because mainly all are installed here. You now know how to copy it.
Now you can extract the files there using:
sudo tar xzvf <filename>.tar.gz
It will extract all files in there.
Now but, we know what does tar do, but what does xzvf do ?
-x/–extract is always required as the first argument when extracting an archive.
“z” is used to “filter the archive through gzip ( you can “j” if you have tar.bz2 file)
“v” is for verbose, to display a list of files/directories involved.. and is probably just personal preference.
“f” is apparently the option to specify the archive file.
And that’s it, you have installed your jdk ! You can delete the tar.gz file to save space.
chmod +x ( change file mode bits ) :
You can type in : man chmod to check out the manual for chmod( yes, man – manual).
chmod +x on file makes it executable. You can refer to my how to install netbeans tutorial to learn how and where to use it.
Now chmod again have many arguments. chmod mainly takes :
- u stands for user.
- g stands for group.
- o stands for others.
- a stands for all.
That means that
chmod u+x <filename> will grant only the owner of that file execution permissions whereas
chmod +x <filename> is the same as
chmod a+x <filename>.
- curl / wget :
In simple words, both are used to download files from the internet.
- wget – is a tool to download files from servers.
- curl – is a tool that let’s you exchange requests/responses with a server.
using -O is important. Because otherwise, it just dumps all the files. Using -O, it downloads the files in the same name as the remote server. In the above example, we are downloading strx25-0.9.2.1.tar.bz2, so the downloaded file will also be the same name.
Suppose you accidentally deleted a file, but you want it back. So, you can revert back your changes !
hg revert –all
or you made changes to a file, but you want the original file back! So,
hg revert <filename>
I suppose, this much would be enough for this post. But there are many other commands which you will learn eventually.