Resources
- Learn Enough Command Line to be Dangerous Show archive.org snapshot (it's in our library => Google Drive Show archive.org snapshot )
- CLI tricks every developer should know Show archive.org snapshot
- Install the
tldrtool usingsudo apt install tldr. You can then get usage examples for every console command, e.g.tldr sshto get examples for thesshcommand. (If there are no entries, runtldr -uand try again)
Exercises
Basic commands
Experiment and do something useful with the following commands. You might need to use tldr or Google the command.
-
man(Get a more colorful output for man pages] topcatlessdpkg -lapt-cache search <text>apt updateapt dist-upgradeapt install <package-name>sudo <command>sudo susshscpdf -h .du -h .-
ss --listening --tcpor (old)netstat --listen --tcp ln -stouchtelnetcurlpskillkill -9pkill -f <partial-name>envdig-
grep(use with|) zgrep <needle> log/*.log*
Configuration files
Understand what you can do with the following configuration files:
~/.bashrc~/.ssh/config~/.gitconfig
Note that changes to your ~/.bashrc don't affect already opened shells.
Terminal editor
To edit files from within a terminal, you'll need a CLI editor.
- Chose an editor (
vim
Show archive.org snapshot
or
nano
Show archive.org snapshot
)
- If you chose vim, learn
how to exit
Show archive.org snapshot
an open editor:
-
:qto exit -
:wqto save (write) and exit -
:q!to exit without writing
-
- If you chose vim, learn
how to exit
Show archive.org snapshot
an open editor:
- Persist your choice in the
$EDITOR
Show archive.org snapshot
variable. It defines the default for commands like
git commit:
# Example with vim
# open the configuration file
vim ~/.bashrc
# navigate to the end of the file,
# press "i" to switch to insert mode
# then type out the line you want to add
export EDITOR=vim
# persist your changes
:wq
Note
While you could set $EDITOR locally to a graphical to a editor like
gedit, this is not possible for remote shells to our servers.
Getting accustomed to a CLI editor will pay off in the long term.
Terminal shortcuts
Understand what the following shortcuts do in a terminal:
- Up-arrow
TabCTRL+R-
CTRL+Z/jobs/fg/bgShow archive.org snapshot- This allows you to faux-multitask within a single shell. E.g. you can temporarily suspend a running vim editor, take a look around the system, then return to your vim editor.
File ownership
Understand access rights and ownership of files:
- What does "ownership" mean for files?
- Each file has 9 flags, 3 read, 3 write, and 3 executable flags. What do they mean?
- Write a simple bash script that prints a message. How can you execute it?
- Write the same script in Ruby. What do you have to do to just call it from the command line without using the
rubycommand directly? Learn about the "shebang".
Posted by Henning Koch to makandra Curriculum (2015-07-08 17:52)