• Martin Thoma
  • Home
  • Categories
  • Tags
  • Archives
  • Support me

Command Line

Contents

  • Command Line
    • The basics
    • Commands
      • Basics
      • Advanced
      • Professional
      • Internet
      • Hardware Analysis
    • Alias
    • The Bang
    • The Dash
    • .dotfiles git repository
    • Tools
    • See also

As a software developer, I work daily many hours on the command line. This article summarizes some tools and tricks to speed up this work.

The basics

Bash, ZSH, Fish are Linux shells.

Oh-my-ZSH is a plugin for ZSH which is AWESOME!

Commands

Basics

  • cd: Change directory, e.g. cd .., cd /home, cd foo/bar/baz
  • pwd: Print the working directory
  • ls: List the contents of the current directory
  • man: show manual / help page
  • history: Show the last commands executed in the shell
  • rm filename.ext removes filename.ext
  • mv filename.ext newname.jpg: Rename a file

Advanced

  • grep: Pattern search
  • cat filename: print the contents of filename to the output
  • watch: run any designated command at regular intervals
  • free: Memory consumption
  • top and htop: display Linux processes
  • find and locate
  • tree: Print a directory tree
  • cloc: count lines of code
  • wc : word count (or lines or characters)

Professional

  • tmux - terminal multiplexer
  • direnv

Internet

  • ping martin-thoma.com: Check if you can reach a domain
  • ssh 123.168.0.1: Connect to the IP 123.168.0.1.
  • screen: Create a new terminal session that can be detached / re-attached
  • ifconfig - configure a network interface

Hardware Analysis

  • lsusb, lspci

Alias

alias pbcopy='xclip -selection clipboard'
alias pbpaste='xclip -selection clipboard -o'

The Bang

There are various commands with the "bang" !:

  • !!: Execute the last executed command in the bash history
  • !*: Execute the command with all the arguments passed to the previous command
  • !ˆ: Get the first argument of the last executed command in the bash history
  • !$: Get the last argument of the last executed command in the bash history

The Dash

cd - jumps back to the directory in which you were before:

/home/moose$ cd foobar
/home/moose/foobar$ cd -
/home/moose$

git checkout - jumps back to the branch in which you were before.

.dotfiles git repository

Dotfiles a files which start with a .. Those files are hidden in Linux and often contain configuration files. Here is mine.

Tools

  • ncdu: Find what is eating your disk space and delete it on the fly.
  • httpie: Command line HTTP client
  • jq: JSON query tool
  • ranger: console file manager
  • tmux

See also

  • Working with Terminal
  • Working at FZI
  • Converting Files with Linux

Published

Okt 9, 2018
by Martin Thoma

Category

Code

Tags

  • Command line 7
  • Development 4

Contact

  • Martin Thoma - A blog about Code, the Web and Cyberculture
  • E-mail subscription
  • RSS-Feed
  • Privacy/Datenschutzerklärung
  • Impressum
  • Powered by Pelican. Theme: Elegant by Talha Mansoor