Linux Basics Tips
Hi nullbytes! I've been recently reading the whole Linux Basics for the Aspiring Hacker series and felt like it was missing some stuff I know, so I felt like sharing it with anyone who might find it useful too.
I wonder why this was omitted in Chapter 5, apt-get is a powerful package and dependency manager! It runs from terminal, and it's good for installing stuff remotely when accessing another Linux box from a SSH.
It's great for regular use too, I use it all the time because it gets things done faster than you would do them on a GUI package manager.
Installing: sudo apt-get install program
Uninstalling: sudo apt-get remove program
Uninstall and remove configuration: sudo apt-get purge program
Upgrade all Packages to their latest version: sudo apt-get upgrade program
Remember to update your database before upgrading your system (sudo apt-get update). You can make it sequential by typing:
sudo apt-get update && sudo apt-get upgrade
This methodology is always good to know (although using gcc is easier)
· Extract the tarball with tar xvf <filename>
· cd into the given directory (usually <filename> without the extension)
· sudo make install
htop gives the option to renice and kill applications, and it more colourful than top. After understanding how each command (ps, top, kill, nice, renice) works, it's a good tool to use.
Same as what I said with htop above, after you understand how each command for processes to know, it's good to make things simple.
Processes can also be killed with the 'killall' command, specifying their process name. For example: killall airbase-ng
It has the same signal codes than kill, so 'killall -9 airbase-ng' will send signal 9 (SIGKILL) instead of 15 (SIGTERM).
This is usually simpler than with PID's, because we already know the name of the commands, right?
This wasn't explained clearly enough (for me, at least) in Chapter 8, and it's a great terminal functionality!
To launch a program so that it is immediately placed in the background, we follow the command with an '&' character: xlogo &
The shell's job control facility also gives us a way to list the jobs that have been launched from our terminal. Using the 'jobs' command, we can see this list. The results show that we have one job, numbered "1", that it is running, and that the command was 'xlogo &'
To return a process to the foreground, use the 'fg' command this way: fg %1
To stop a foreground process, type 'Ctrl-Z'. We can verify that the program has stopped by attempting to resize the 'xlogo' window. After stopping 'xlogo', it appears quite dead. If you cast a 'kill' or 'killall' command on a stopped process, it'll stop right after you start it again.
We can either restore the program to the foreground using the 'fg' command, or move the program to the background with the 'bg' command: bg %1
To kill most processes running on the current terminal window, you can use Ctrl-C.
I felt like this command was missing from Chapter 10. Hence the "funny" title.
The command 'nano' can be used as a simple text editor on terminal, without having to go graphical with programs like gedit, geany, kwrite, etc. Or overcomplicating life with editors like ViM or Emacs (although its really good to learn one of those). To edit simple configuration files (specially when SSHing), use 'nano', or 'sudo nano' followed by the name of the file you want to edit. For example: sudo nano /etc/apt/sources.list
After you're done editing, 'Ctrl-X' to exit, then 'y' to overwrite previous file (or 'n' to not do so), 'Enter' to save with the same filename, and you're done!
I use Crunchbang and Apache doesn't come bundled with it, so I had to get it. This relates to Chapter 11.
A simple way to install Apache is to just type: sudo apt-get install apache2
To start Apache daemon: sudo /etc/init.d/apache2 start
To stop Apache daemon: sudo /etc/init.d/apache2 stop
Neither does come MySQL along with my distro. This is related to Chapter 14
To install, follow this steps:
2. If you get the apt-configurator, choose options for your installation, then choose option 'Apply' (or it will loop indefinitely). If you get source code, follow the process to install from source.
3. And then: sudo apt-get install mysql-server
Start MySQL daemon: sudo /etc/init.d/mysql start
Stop MySQL daemon: sudo /etc/init.d/mysql stop
I already commented this on Chapter 16, but I felt like adding it here too.
You can do this simply by typing:
ls /etc/hosts /etc/aircrack-ng &> goodoutput
This relates to Chapter 17.
Google's DNS tend to be the fastest on many countries (including mine). To use them, simply: sudo nano /etc/resolv.conf
And then add these lines before anything else (unless you have a local DNS set):
Not directly related to Chapter 19, but it has a similar functionality and its great to know.
Open a terminal and type: nano .bash_aliases
There you can add aliases using this format:
alias <name of alias>='<commands alias will represent>'
For example, I have Tor browser on a folder right into my root directory, to get things ordered up. Tor requires to be standing on it's folder to launch itself, so I made this alias:
alias tor-browser='cd /kitten/tor-browser && ./start-tor-browser && cd -'
I saved the file, restarted the system, and the alias was then available on my system!
It can be used for anything you can imagine! *cough* shell scripting *cough*
With this, when I type 'tor-browser', my terminal automatically moves to /kitten/tor-browser directory, launches Tor with './start-tor-browser', and then returns to previous standing directory with 'cd -'. Pretty useful, right?
I'd like to thank OTW for writing all these guides, as they really helped me remember stuff I had long forgotten, and finally learn some things I was reluctant to read about. Many, many thanks. I hope this series continues :)