Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
home_server:home_server_setup:other_services:bash [2023-03-19 Sun wk11 13:35] – [exa] baumkphome_server:home_server_setup:other_services:bash [2025-08-16 Sat wk33 19:41] (current) – [create] baumkp
Line 1: Line 1:
-{{tag> linux bash alias .bash_aliases configure configuration bashrc command script .bashrc history sudo visudo dimmer nightmode xrandr tar archive}}+{{tag> linux bash alias tar .bash_aliases configure configuration bashrc command script .bashrc history sudo visudo dimmer ps kill nightmode xrandr tar archive "default editor" editor}}
 ======BASH Customisation====== ======BASH Customisation======
 The standard BASH colour configuration uses a blue colour for listing directories (ls) which is difficult to read on a black background. While this is the "standard colour", due to the impracticality I have decided to change it. The standard BASH colour configuration uses a blue colour for listing directories (ls) which is difficult to read on a black background. While this is the "standard colour", due to the impracticality I have decided to change it.
Line 10: Line 10:
  
 Add the following commands to ''vim ~/.bashrc'', the aliases can also be added to the separate file .bash_aliases, ''vim ~/.bash_aliases'': Add the following commands to ''vim ~/.bashrc'', the aliases can also be added to the separate file .bash_aliases, ''vim ~/.bash_aliases'':
-   *''alias ll=%%'ls -la --color=auto'%%''+   *''alias ll=%%'ls -lah --time-style=long-iso --color=auto'%%''
    *''alias lh=%%'ls -laL --color=auto'%%''    *''alias lh=%%'ls -laL --color=auto'%%''
    * key ''ls'' options :    * key ''ls'' options :
Line 21: Line 21:
        * ''-S'' : sort by file size, largest first        * ''-S'' : sort by file size, largest first
        * ''-t''  : sort by time        * ''-t''  : sort by time
 +       * ''%%--time-style%%'' : allows the displayed time sytle to be changed.
 +           * The standard output is a disgrace, North American mixed up! Aug 23 2022 or Jan 1 11:44 for nearer dates.
 +         * ''iso'' gives 2023-01-23 for more than a year past and 10-23 15:51 for less than a few months past, yuk!
 +         * ''long-iso'' always gives yyyy-mm-dd hh:mm, without a doubt the best format, clean and consistant!
 +         * ''full-iso'' is same as long-iso, except time time is to the nanosecond and local timezone delta is displayed 
 +         * The ''TIME_STYLE'' environment variable sets the default
 ++++An example alias file:| ++++An example alias file:|
 <code bash> <code bash>
Line 362: Line 368:
   * danyspin97's site [[https://danyspin97.org/blog/colorize-your-cli/|Colorize your CLI]]   * danyspin97's site [[https://danyspin97.org/blog/colorize-your-cli/|Colorize your CLI]]
   * [[https://www.gnu.org/software/bash/manual/html_node/index.html#SEC_Contents|Bash Reference Manual]]   * [[https://www.gnu.org/software/bash/manual/html_node/index.html#SEC_Contents|Bash Reference Manual]]
-  * shopt [[https://www.gnu.org/software/bash/manual/html_node/The-Shopt-Builtin.html|The Shopt Builtin] sh options, simply type ''shopt'' to see list with current settings.  Looks like built ins only?+  * shopt [[https://www.gnu.org/software/bash/manual/html_node/The-Shopt-Builtin.html|The Shopt Builtin]] sh options, simply type ''shopt'' to see list with current settings.  Looks like built ins only?
   * set [[https://www.gnu.org/software/bash/manual/html_node/The-Set-Builtin.html|The Set Builtin]] set options, ''set'' on its own list entire content. (Looks like user defined?)   * set [[https://www.gnu.org/software/bash/manual/html_node/The-Set-Builtin.html|The Set Builtin]] set options, ''set'' on its own list entire content. (Looks like user defined?)
  
Line 374: Line 380:
 I tried it and could not be bothered with it and uninstalled. I tried it and could not be bothered with it and uninstalled.
  
-=====grc=====+====grc====
 General colouriser.  I installed it but do not bother to use it normally.  General colouriser.  I installed it but do not bother to use it normally. 
  
-=====ble.sh=====+====ble.sh====
 ble.sh is a tool for bash that add command line continuation and colouring as well as other features. ble.sh is a tool for bash that add command line continuation and colouring as well as other features.
  
Line 387: Line 393:
   *[[https://github.com/akinomyoga/ble.sh|ble.sh ―Bash Line Editor―]]   *[[https://github.com/akinomyoga/ble.sh|ble.sh ―Bash Line Editor―]]
  
-=====BASH Prompt=====+====BASH Prompt====
 I like a standard looking prompt, none of these Apple look alike things that seem to be popular on the nerd media at the moment.  I do not see much value in the prompt showing the date as this is shown on the main GUI screen. I like a standard looking prompt, none of these Apple look alike things that seem to be popular on the nerd media at the moment.  I do not see much value in the prompt showing the date as this is shown on the main GUI screen.
  
 References References
   *[[https://www.howtogeek.com/307701/how-to-customize-and-colorize-your-bash-prompt/|How to Customize (and Colorize) Your Bash Prompt]]   *[[https://www.howtogeek.com/307701/how-to-customize-and-colorize-your-bash-prompt/|How to Customize (and Colorize) Your Bash Prompt]]
-=====Colors=====+====Colors====
 Seems like the main terminal colors is 1bit (light and dark), 4 bit or 16 colors, while "expanded" is 256 colors.  The pallet the colors can be selected from can be varied from 24bits (16M) on more modern systems. Seems like the main terminal colors is 1bit (light and dark), 4 bit or 16 colors, while "expanded" is 256 colors.  The pallet the colors can be selected from can be varied from 24bits (16M) on more modern systems.
 The LS command allows the colors to be changed via the LS_COLOR environment variable. The LS command allows the colors to be changed via the LS_COLOR environment variable.
Line 436: Line 442:
 ====create==== ====create====
 main ''tar'' create options, e.g.: ''tar -cvf archive_filename.tar file1 directory1 file2'' main ''tar'' create options, e.g.: ''tar -cvf archive_filename.tar file1 directory1 file2''
-  *''-c'' : for create archive, a pretty self-explanatory option if you want to create a new archive made from the files selected; +  *''-c'' : for create archive, a pretty self-explanatory option if you want to create a new archive made from the files selected.  The ''c'' option should be first.   
-  *''-v'' : for verbose, this is the reason why the command displays the files added to the archive when executing it; +  *''-v'' : for verbose, this is the reason why the command displays the files added to the archive when executing it. 
-  *''-f'' : for file, this option is used in order to specify the filename of the archive we want to create (in this case archive.tar)+  *''-f'' : for file, this option is used in order to specify the filename of the archive we want to create (in this case archive.tar), The ''f'' option should be just before the file name.
  
 +If backing up a root directory use the following as an example: ''sudo tar -czvPf filename /etc'' a better example is ''sudo tar -czvf filename -C / etc''
 +  *''-P'' : for Don't strip leading slashes from file names when creating archives.  This is not recommended as the absolute path will overwrite the information in the root directory, which will often and mostly lead to undesirable outcomes.  This is why the ''tar'' command will usually strip leading absolute path references to root directory, that is paths starting with ''/''.
 +  *''-C'' : for change to directory.  This changes the directory to ''/'' and then copies the files into the archive with relative paths, that is without the leading ''/''
 ====extract==== ====extract====
 ''tar -xvf archive_filename.tar'' ''tar -xvf archive_filename.tar''
Line 446: Line 455:
 ====list contents==== ====list contents====
 ''tar -tvf 'archive filename''' ''tar -tvf 'archive filename'''
 +  *''t'' will list the contents of the archive.
 +  *''v'' will list all the file parameters, without just the file path/name only.
 +=====ps process=====
 +''ps aux'' to see current process
 +
 +=====kill process=====
 +''killall name''
 +''pkill name''
 +''pkill -9 name''
 +
 =====compression===== =====compression=====
 Use either ''gzip'', ''bzip2'', or ''xz'' to directly compress a file Use either ''gzip'', ''bzip2'', or ''xz'' to directly compress a file
Line 451: Line 470:
   *''bzip2'', extension ''.bz2'', with ''tar'' use flag ''-j''   *''bzip2'', extension ''.bz2'', with ''tar'' use flag ''-j''
   *''xz'', extension ''.xz'', with ''tar'' use flag ''-J''   *''xz'', extension ''.xz'', with ''tar'' use flag ''-J''
 +
 +=====copy & paste=====
 +See [[https://wiki.kptree.net/doku.php?id=home_server:home_server_setup:other_services:misc#pbcopy_pbpaste|pbcopy pbpaste]]
 +=====Change Default System Editor=====
 +Use ''sudo update-alternatives --config editor'' and follow prompts on screen
 +
 +Reference: 
 +  *[[https://unix.stackexchange.com/questions/42726/how-do-i-change-the-default-text-editor-in-the-debian-squeeze-distro|How do I change the default text editor in the Debian (squeeze) distro]]
 +  *[[https://www.baeldung.com/linux/update-alternatives-command|The update-alternatives Command in Linux]]
 +
 <- home_server:home_server_setup:other_services:ssh|Prev ^ home_server:home_server_setup:other_services:index|Start page ^ home_server:home_server_setup:other_services:conky|Next -> <- home_server:home_server_setup:other_services:ssh|Prev ^ home_server:home_server_setup:other_services:index|Start page ^ home_server:home_server_setup:other_services:conky|Next ->