Linux


Last updated: Jun 01, 2015

 

Table of Contents


  1. Introduction


  2. Ubuntu


  3. Files, Directories, etc


  4. User Management


  5. Find Command


  6. Processes


  7. Services


  8. Grep


  9. Wget/Curl


  10. Screen


  11. Tmux


  12. IPTables


  13. ufw


  14. Hardware


  15. Gnome


  16. Bash


  17. Package Management


  18. Miscellaneous


  19. Favorite Apps


 

Introduction

I have been using Linux for approximately 15 years. I have used many distributions: Redhat, Gentoo, Debian, Ubunutu, Yoper, Slackware, and currently I am using Linux Mint which I really like. The following document is a list of commands that I have saved over the years. Some may call it a Linux reference document and others a Linux cheatsheet. Most of these commands are not basic commands and if you are new to Linux you should read some "newbie" type documents first. I recommend this one.

If you feel any of the content in this document is wrong or there is something that I should add, I would appreciate it if you would contact me and let me know. Thanks!

 

[Table of Contents]

 

 

Files, Directories, etc.

Here are useful commands for doing different things with files, directories, processes, etc:

 

[Table of Contents]

 

 

Ubuntu Versions

The Ubuntu versions: *Note, LTS stands for "Long Term Support"

 

[Table of Contents]

 

 

User Management

 

[Table of Contents]

 

 

Find Command

Here are some useful find commands:

 

[Table of Contents]

 

 

Processes

 

[Table of Contents]

 

 

Services

For most of the Linux distros I have used, you can use the wonderful "chkconfig" tool to manage what services get started on boot. Some distros come with chkconfig by default and others you have to install the package. Note,if you get the error message "/sbin/insserv: No such file or directory" then link it like this to resolve: ln -s /usr/lib/insserv/insserv /sbin/insserv

Here are my favorite chkconfig commands: I use to use /etc/init.d/servicename start to start/stop/restart a service, but I now use service <servicename> start (or stop or restart)

Update - I found that chkconfig was not disabling some services completely in Linux Mint 13 (this is also probably the case with newer versions of Ubuntu). I did some research and found the correct way to disable a service is with upstart. Here are some commands: There is a lot more to upstart. I recommend you read the Upstart Cookbook to find out more.

 

[Table of Contents]

 

 

Grep

 

[Table of Contents]

 

 

Wget/Curl

 

[Table of Contents]

 

 

Screen

Screen is one of the most useful programs. If you are not using it, I strongly suggest you look into starting. Here is my .screenrc file. Just place it in your home directory and the next time you launch screen the changes will take effect. It is well commented so you can have a look at the file to see what it does. Also make sure you rename the file to .screenrc when you place it in your home directory.

Here are my favorite screen commands (note, C-z is a shorthand way of writing "press down the Ctrl key and the z key together." You will often see this syntax in screen and tmux documentation): My favorite way to start screen is screen -DR. There are MANY options to screen. Look at the man page to view them all.

To have commands added to your history file when using screen:

 

[Table of Contents]

 

 

Tmux

Everytime I read anything about screen, someone almost always mentions tmux and they usually say it is a better alternative, so I finally decided to check it out. So far I like it.

Below are some useful commands I have learned so far (note, the default control key is C-b but I prefer to map mine to C-z. Everyone uses C-a, but I do not like this because I am always using C-a in bash to go to the beginning of a line and this conflicts with that. Also, just like with screen, when I write C-z this is short for "press the Ctrl key and the z key together").
Some useful tmux commands (you can either enter these on the command line (ie. tmux list-sessions), or using C-z : (note the colon!) then the command (which gives you the additional benefit of having tab completion and command history):
These are commands to work with window panes in one window. Note, that some of these are customized in my .tmux.conf file you can download below. I will make a note if they are custom:
Note, if you are having trouble with tmux (ie. keybindings are not working) make sure your config file is named ".tmux.conf" exactly! I spent way too trying to figure out why it was not working when I had it named ".tmux_conf" (I copied it from a backup)

Here is my .tmux.conf file and here is a script I wrote to start tmux with a number of open windows named the way I want them and a few connected to my desktop via ssh.

Just like screen, there many things you can do with tmux. Here are some useful resources:

 

[Table of Contents]

 

 

IPTables

 

[Table of Contents]

 

 

ufw

Ufw is a program for managing netfilter/iptables rules. It stands for "uncomplicated firewall" and if you ever managed more then a simple iptables ruleset, then you will understand this meaning. Here are some useful examples:

 

[Table of Contents]

 

 

Networking

These are commands related to networking:

 

[Table of Contents]

 

 

Hardware

 

[Table of Contents]

 

 

Gnome

Here are useful Gnome related commands:
These are useful Gnome3 shortcuts. They may work in other versions of Gnome, I have never tested them.

 

[Table of Contents]

 

 

Bash

Some of my favorite bash commands/tricks:

 

[Table of Contents]

 

 

Crontab

Crontab