Manage your configuration like code
Suppose you need to work on another machine, saving your configuration in GitHub will save you much time when re-customize your working environment.
Many developers already do the same thing. Manage any configuration(.bashrc, .vimrc, .emacs, etc) with Git is a good habit you should develop from the beginning of working on
The benefits of managing configurations with Git is:
- Reviewing your change history, which is useful for troubleshooting.
- Accumulating the tips and configuration.
- Use it on multiple machines.
If you are not ready to share your configuration with others, use a
private GitHub repo for security.
Currently, we can use private repo in GitHub without pay any fees.
Remember to add sensitive files into .gitignore, and
DO NOT push files which contain password or secrets into GitHub.
I saw many developers pushed sensitive files into GitHub, and got security issues. Don’t be a fool.
How to get help
Don’t be afraid of so many commands options in the command line working environment.
Developers don’t need to remember everything,
The manual and documents are organized in the same pattern and Google is your final lifebuoy.
Whenever you need help for any command, try these:
man to query the manuals
man used to display the user manual of any command that we can run on the terminal.
On Ubuntu/Debian, you need to install it from the terminal:
sudo apt-get install man.
Except for querying the manual of command, you can also use
man to read the manual and details of the function or files you are interested in.
man exec will display on screen:
Use command with
Any command or script will come with a help message. Whenever you don’t know which option to use for your task, have a try on
command --help. Linux/Unix help messages usually designed in a similar format, you need to adapt to it.
Learn how to google effectively as a developer, it needs time but rewarding for your development life.
You should know using which keywords to search for command line issues.
For Linux commands “Linux command
#keyword#“ should be a good try.
Shell aliases are the most useful tips when you working on Linux/Mac.
Whenever you think one command line will be repeated later(especially the long one), you should add it to your configuration as a
Part of my configuration includes:
Other handy aliases:
30 Handy Bash Shell Aliases For Linux / Unix / Mac OS X
A few more of my favorite Bash aliases
go back to the previous working directory
Suppose you change current working directory into /tmp, finished some tasks and want to go back to the previous working directory, in this case,
cd - will help you saving time.
execute the command in history
history will show the commands executed recently
From the output,
!5 will re-execute command ‘pwd’ If you want to re-execute the last command, you could use
!! to finish it.
free/top used to display the usage statistics of resources, like memory and CPU usage. A more friendly alternative is
htop, which display all kind of statistics with visualization.
netstat is a command-line network utility that displays network connections for Transmission Control Protocol, routing tables, and several network interface and network protocol statistics.
More usage examples listed here.
Combine commands for your task
The best way to use the Linux/Unix is to use the commands like awk, sed, grep, xargs, find, sort, etc., combine them into the function you wanted. Just like what’s I have done for Git repo checking.
Most of the simple tasks like grep word from files, filter files with pattern can be finished with these tiny commands.
cat/head/tail : show the content of files, bat is a Rust clone of
cat, which supports syntax highlighting for a large number of programming and markup languages.
grep : Search any line that contains the keyword in a file.
sort: sorts the contents of a text file, line by line.
uniq : Remove duplicated parts from string or files.
find : Find or filter files with patterns.
xargs : Allows tools or commands to accept standard input as arguments.
awk : A scripting language used for manipulating data and generating reports.
Some fancy tools which power your productivity
httpie is a fancy command line HTTP client with an intuitive UI, it also supports JSON format, with highlighting, and many plugins. Maybe you have used
wget, you will forget them when you have tried
tmux is a terminal multiplexer, it can manage windows and sessions in your terminal. You can split the screen into multiple sub-panels, you can also detach and re-attach sessions.
If you want to connect to remote servers frequently, this is an invaluable tool for you.
Which shell to use
Bash is the default shell on many Linux distributions today.
Zsh is a modern one with features of other Unix/GNU Linux shells such as bash, tcsh, and ksh.
Fish is a smart and user-friendly command-line shell for Linux, macOS. It supports powerful features like syntax highlighting, autosuggestions, and tab completions that just work, with nothing to learn or configure.
If you work on Mac: Zsh on iterm2 is my most recommended one.
Oh My Zsh is a delightful, open-source, community-driven framework for managing your Zsh configuration. With the configuration from the community, it saves much of your time.
tmux guide: https://www.hamvocke.com