Quick tips -> Using the Linux Command line

One of my favorite things about using the Linux command line for any applicable tasks is that there’s usually at least one way to simplify a long list of operations down to just a few keystrokes. The tips below, some of which are major time-savers, are things I learned from friends, the internet, or discovered by accident.

Moar Dots

Most of us learn to exit out of file directories by repeatedly typing “cd ..” into one prompt after another. Eventually we graduate to using a sequence of dots and slashes eg. “../../../../” at the prompt. But even this method is not lazy enough, so I stumbled on a quicker way which involves typing any number of periods(eg. cd .... into the console to travel up the same number of directories. This trick won’t work out of the box on certain Linux distrubutions and shells, but the aliases below suggested by Max Hoffman work great for acheiving consistent, “more dots” behaviour across all shells.
 
#travel up through directories, one more level for each additional period
alias ..="cd .."
alias ...="cd ../.."
alias ....="cd ../../.."
alias .....="cd ../../../.."
alias ......="cd ../../../../.."
alias .......="cd ../../../../../.."
	
Check out the full article for more great tips:
https://mhoffman.github.io/2015/05/21/how-to-navigate-directories-with-the-shell.html

$OLDPWD

The $OLDPWD variable always evaluates to the path of the previously visited direcotory, which makes it a convenient way to hop back-and-forth between any two directories.

Color Always

When text output from commands like ls -la is redirected or piped to pagers like less, any text formatting color is often lost. Some Linux programs provide a --color flag. Set --color=always to keep terminal color codes which can then be interperated by programs like “less -R” to view the colors.

Cleaner output with ls -1

ls -l gives a detailed list of files and directories, which sometimes is more information than desired. When you just want newline seperated filenames to pipe to another program, like sort, use the -1 ( minus one ) flag ls -1.

Use Explain Shell

There’s an awesome online tool for deciphering shell commands called Explain Shell. It’s saved me loads of time and is great for tracking down explanations for before running them commands. When in a hurry , I use Explain Shell to get the jist of what in unfamiliar command does, without having to dig through the man pages. Many man pages and info sections are massive tomes of information and are great references for unfamiliar programs, but slower to skim for the important bits. Over the years I’ve spent as web admin, I’ve encountered many roadblocks to proper development of the site or implementation of a feature. Sometimes bugs, and at other times incompatibilities, require that I borrow solutions from online forums or develper blogs. In those cases, I feel responsible for undstanding any copied commands well before attempting to run them.

Set $MANPAGER To Vim

Some program manuals contain references to so many other programs, that reading through them feels like getting lost in an endless system of ant tunnels. Quickly jump between man pages with Vim’s CTRL-K command which works by passing any text under the cursor as an argument to man eg. man text_under_vim_cursor .Vim’s man-page browsing feature comes in handy, for anyone who insists on mannually going down the rabbit hole.😉

Crawl manuals with man’s -K flag

Most Linux users will be aware of the lowercase -k flag for finding programs by keywords. This search is fast but only checks program descriptions, instead of the full text of a program’s manual files. For a more thorough search, use man -K the_search_term and use CTRL-D to skip irrelevant results. The downside to this is the search could easily take a couple minutes to complete. Also many irrelevant results will be returned during the search, each time, and for each match , the search will stop to wait for action from the user before continuing.

How shared-hosting plans restrict project freedom

The most popular hosting companies offer direct access to the hosting server via Secure Shell Access, or SSH. Access to a shell gives site-owners a greater control, and opens up more possibilities for adding features or testing site performance. However because the hosting is shared, you will have restricted access to package managers, the gnu c compiler, make etc. In other words, to install any non-standard programs, you will need permission from your hosting company and sometimes pay an extra fee. Does your web-project require using of certain tools like Java? Do you prefer to work with python 3.x instead of python 2.x. If so then most shared-hosting plans will not be adequate. Below are the results from my investigation of a few popular hosting companies for program availability in general. I also checked for access to gnu c compiler which would allow us to manually install most new programs over SSH.     Bluehost is pretty restrictive and does not allow access to gcc. Also, java is not included at all. HostGator doesn’t include the gcc. Take a look at the HostGator software compaibility list for quick idea of what’s available. Godaddy‘s hosting gives full permissions to use gcc! You will have to be okay with be running on an almost 10 year old kernel version 2.6.x . Site Ground offers relatively more recent versions of software.However, Users are denied permission to use gcc and c make. Depending on how “custom” your setup needs to be, you may expect to pay for such service( $49 for a one time technical request on Siteground ). At that point it might be worth upgrading to a dedicated hosting plan instead.

Conclusion

Most hosting companies are willing to install some non-standard programs on behalf of a customer. But SiteGround, HostGator, and BlueHost all refuse to setup gcc on my request. It’s safe to assume most other companies will do the same in the interest of server performance and security. If this seems like a huge let down, I’m happy to say there is still hope. You may be able to install gcc without sudo.