-
Notifications
You must be signed in to change notification settings - Fork 0
General
GradedJestRisk edited this page Sep 12, 2019
·
17 revisions
RTFM : man COMMAND_NAME
List:
- kernel:
uname -r
- distribution:
lsb_release -a
- file manager
xdg-mime query default inode/directory
All mount element in /etc/fstab
are mounted on startup (except those with noauto option).
Get default terminal (look for *)
sudo update-alternatives --config x-terminal-emulator
Default config file is ~/.bashrc
, loaded at terminal start
Overview
- list
alias
- add
alias ALIAS_NAME='COMMAND'
- remove
unalias ALIAS_NAME
- run without alias
\command
- in list
- directories blue and DIRECTORY_NAME/
- readable size
- print only file modification date and file name
- aligned
Gives
alias ls='ls -lFh --color=always | awk '\''{print $5,$6,$7,$8,$9}'\'' | column -t'
Alter PS1 variable in .bashrc
PS1='\u \w $ '
=> USER_NAME WORKING_DIRECTORY $
To format the prompt, use ASCII escape sequence
Open | Body | Close | |
---|---|---|---|
\[
|
ESCAPE_SEQUENCE
|
\]
|
Here's the codes
Need | Syntax | Full (use around $foo) | |
---|---|---|---|
red |
\e[31m
|
\[\e[31m$foo\]
|
|
blue |
\e[36m
|
\[\e[36m$foo\
|
|
bold |
\e[1m
|
\[\e[1m$foo\
|
|
reset |
\e[0m
|
No use with $foo
|
Always add \[\e[0m\]
at end of PS1
To get local-function feedback
PS1='$(FUNCTION_NAME) :'
To dynamically return color-code
set_bash_prompt(){ PS1="[\w] $(COLORCODING_FUNCTION_NAME) \$ " } PROMPT_COMMAND=set_bash_prompt
Overview:
- list last 5 modified files
ls -ltr | tail -5
- get total size of files in directory matchin pattern
du -csh *temp* | tail -1 | cut -f 1
Identify the binary location of a command
which COMMAND_NAME
User initialization scripts:
- main :
~/.bash_profile
- main in Ubuntu:
’~/.profile`
- system-wide environment variables
/etc/environment
- all:
echo exit | strace bash -li |& less | grep '^open'