More on this book
Community
Kindle Notes & Highlights
The first time you connect to a particular server, PuTTY will ask to cache that server's host key.
Having an SSH key without a passphrase can allow you to automate and schedule tasks that require logging in to remote systems.
In order to create an SSH key on a Windows system, you will need PuTTYgen.
I highly recommend naming the keys in the following format: id_rsa and id_rsa.pub or id_dsa and id_dsa.pub Otherwise, you will have to specify the location of your key when you use the ssh command or perform some additional configuration to tell SSH that your keys are not named in the standard way.
(~). The tilde is a shorthand way of representing your home directory.
/etc System configuration files.
/var Variable data, most notably log files.
man command - Displays the online manual for command
exit, logout, or Ctrl-d - Exits the shell or your current session.
environment variable that represents your previous working directory is OLDPWD. So, cd - and cd $OLDPWD are equivalent.
Here are two ways to execute program. $ pwd /home/bob $ ./program $ /home/bob/program
If you want to show a long ls listing with hidden files you could run ls -l -a or ls -la.
A link is sometimes called a symlink, short for symbolic link. A link points to the location of the actual file or directory. You can operate on the link as if it were the actual file or directory. Symbolic links can be used to create shortcuts to long directory names. Another common use is to have a symlink point to the latest version of installed software as in this example.
tree - List contents of directories in a tree-like format.
If you happen to see an extra character at the end of the permissions string an alternative access control method has been applied. If you see a period (.), the file or directory has an SELinux (Security Enhanced Linux) security context applied to it. If you see a plus sign (+), ACLs (Access Control Lists) are in use.
If you do not specify permissions following the equal sign, the permissions are removed.
There is a class of special modes. These modes are setuid, setgid, and sticky. Know that these special modes are declared by prepending a character to the octal mode that you normally use with umask or chmod. The important point here is to know that umask 0022 is the same as umask 022.
setuid permission - Allows a process to run as the owner of the file, not the user executing it. setgid permission - Allows a process to run with the group of the file, not of the group of the user executing it. sticky bit - Prevents a user from deleting another user's files even if they would normally have permission to do so.
Let's look at some examples. Let's say you are looking for a file or directory named "apache." You think it is in /opt somewhere and are not quite sure if it is "Apache" or "apache." You could provide find with the path of /opt, use -iname to ignore case, and look for "apache." $ find /opt -iname apache
Every time you run the find command it evaluates each file and returns the appropriate response. This can be a slow process at times. For instance, if you are looking for a file on the system and cannot narrow its location down to a subdirectory you would run find / -name something. That command looks at each and every file on the system.
if you are trying to keep up with changes that are being made in real time to a file, cat is not the best choice. A good example of files that can change often and rapidly are log files. For example, you may need to start a program and look at that program's log file to see what it is doing. For this case, use the tail -f file command. tail -f file - Follow the file. Displays data as it is being written to the file.
vim [file] - Same as vi, but with more features.
:w! - Forces the file to be saved even if the write permission is not set. This only works on files you own.
:q! - Quit without saving changes made to the file.
screenshot of vim. Tildes (~) represent lines beyond the end of the file.
If you would like to insert a piece of text 80 times, type 80i and start entering the text.
dw - Delete a word. To delete five words, type d5w. The repeating concept in vi shows up in many places. dd - Delete a line. To delete 3 lines, type 3dd. D - Delete from the current position to the end of the line.
emacs - Emacs has a graphical mode, too. gedit - The default text editor for the Gnome desktop environment. gvim - The graphical version of vim. kedit - The default text editor for the KDE desktop environment.
vimdiff file1 file2 - Highlight the differences between two files in the vim editor.
sort -u file - Sort text in file, removing duplicate lines.
If you run across an older version of tar without gzip compression built-in, you can use pipes to create compressed archives.
There are three default types of input and output. They are standard input, standard output, and standard error.
Linux represents practically everything as a file. This abstraction allows you to do powerful things like take the standard output of one command that would normally be displayed to your screen and use it as input to another command. It's easier to run cat file.txt | sort than it is to type the entire contents of file.txt as the input to the sort command.
Use the greater-than sign (>) to redirect output and the less-than sign (<) to redirect input.
ls -lF /opt/apache > files.txt is the same as ls -lF /opt/apache 1> files.txt.
sort < files.txt is the same as sort 0< files.txt.
To redirect the error messages you had to explicitly specify file descriptor 2 with 2>.
If you want to capture both standard output and standard error, use 2>&1.
>/dev/null - Redirect output to nowhere.
SCP and SFTP are both extensions of the secure shell (SSH) protocol.
In order to use SCP or SFTP you need a client. Mac and Linux come with scp and sftp command line utilities. If you are running Windows, you can use the PuTTY Secure Copy Client (pscp.exe) and the PuTTY Secure File Transfer client (psftp.exe) programs.

