Skip to content

Instantly share code, notes, and snippets.

@prashanta
Last active January 7, 2022 23:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save prashanta/4600997 to your computer and use it in GitHub Desktop.
Save prashanta/4600997 to your computer and use it in GitHub Desktop.
Collection of shell commands/scripts

Common Linux Commands

Contained here are trival stuffs. Like with all trival stuffs, its inevitably bound to be forgotten.

Description Command
List only directories ls -l | grep ^d
Count number of files & directories ls -l | tail +2 | wc -l
Command prompt coloring__ (Add to ~/.bash_profile) \n Color reference here export PS1="\e[36;1m[\W] \e[0m"
Colorizing terminal (Add to ~/.bash_profile) export CLICOLOR=1 \n export LSCOLORS=gacadxFxCxDxBxegedabagace

More info here

Find Files and Directory

Find directory with name containing log in current directory

find . -type d -name '*log*'

Find file with name containing server in current directory

find . -name '*server*'

Using xargs

First list active docker containers and pipe that to xargs to run docker inspect

docker ps -q | xargs -n 1 -I % -p docker inspect % -f "{{json .NetworkSettings.Networks}}"

User Management

  • Create new user

@prashanta
Copy link
Author

prashanta commented Jan 23, 2013

View this gist here: https://gist.io/@prashanta/4600997

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment