User Tools

Site Tools


linux_notes

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
linux_notes [2021/03/08 18:22] – [combine multiple jpegs into one pdf] rajulinux_notes [2023/09/24 15:33] (current) – [what is my OS?] raju
Line 2: Line 2:
   * [[add numbers on the command line]]   * [[add numbers on the command line]]
   * [[du on month end dates]]   * [[du on month end dates]]
 +  * [[change the default shell]]
 +  * [[Which shell am I using | Which shell am I using?]]
 +  * [[Difference between SHELL and 0 | What is the difference between \$SHELL and \$0?]]
  
-==== combine multiple jpegs into one pdf ==== +==== what is my OS? ====
-snippet 1:+
 <code> <code>
-convert *.jpg file.pdf+awk -F= '$1=="ID" {print $2}' /etc/os-release
 </code> </code>
  
-snippet 2:+Sample run:
 <code> <code>
- % cat combine_pics.sh  +% cat /etc/os-release 
-#! /usr/bin/env bash+PRETTY_NAME="Debian GNU/Linux 12 (bookworm)" 
 +NAME="Debian GNU/Linux" 
 +VERSION_ID="12" 
 +VERSION="12 (bookworm)" 
 +VERSION_CODENAME=bookworm 
 +ID=debian 
 +HOME_URL="https://www.debian.org/" 
 +SUPPORT_URL="https://www.debian.org/support" 
 +BUG_REPORT_URL="https://bugs.debian.org/" 
 +</code>
  
-script_dir=`dirname "$0"+<code> 
-cd $script_dir/bin +% awk -F'$1=="ID" {print $2}' /etc/os-release      
-convert `ls -v individual_pics/*.jpeg` all_pics_combined.pdf+debian
 </code> </code>
  
-Ref:- https://stackoverflow.com/questions/13618236/merge-multiple-jpg-into-single-pdf-in-linux+Ref: 
 +  * I came across it in https://github.com/trimclain/.dotfiles/blob/main/Makefile 
 + 
 +==== last reboot times ==== 
 +<code> 
 +last reboot --time-format full 
 +</code> 
 + 
 +Sample run 
 +<code> 
 + % last reboot --time-format full 
 +reboot   system boot  5.10.0-17-amd64  Tue Dec  6 08:18:33 2022   still running 
 +reboot   system boot  5.10.0-17-amd64  Tue Dec  6 08:11:34 2022 - Tue Dec  6 08:17:36 2022  (00:06) 
 +reboot   system boot  5.10.0-17-amd64  Tue Dec  6 07:41:53 2022 - Tue Dec  6 08:11:01 2022  (00:29) 
 +reboot   system boot  5.10.0-17-amd64  Sat Dec  3 13:18:10 2022 - Tue Dec  6 08:11:01 2022 (2+18:52) 
 +reboot   system boot  5.10.0-17-amd64  Sat Dec  3 13:04:06 2022 - Tue Dec  6 08:11:01 2022 (2+19:06) 
 +reboot   system boot  5.10.0-17-amd64  Wed Nov 16 11:18:41 2022 - Tue Dec  6 08:11:01 2022 (19+20:52) 
 +reboot   system boot  5.10.0-17-amd64  Mon Sep  5 21:26:07 2022 - Wed Nov 16 11:18:01 2022 (71+14:51) 
 +reboot   system boot  5.10.0-16-amd64  Mon Aug 15 05:27:05 2022 - Mon Sep  5 19:36:09 2022 (21+14:09) 
 +reboot   system boot  5.10.0-16-amd64  Mon Aug  1 17:56:22 2022 - Mon Aug 15 05:26:20 2022 (13+11:29) 
 +... 
 +</code> 
 + 
 +{{tag>["reboot history" "show year" "date format"]}} 
 +==== ls and mv ==== 
 +Sample command 
 +<code> 
 +ls -rt *.txt | tail -n5 | tr '\n' '\0' | xargs -0 -i% mv % x1 
 +</code> 
 + 
 +Notes: 
 +  * Works even if there are spaces in the filenames. Compare this with <code> 
 +mv `ls -rt *.txt | tail -n5` x1 
 +</code> which will not work if there are spaces in the filenames. 
 +  * Does not work if the filenames contain newline characters. 
 + 
 +Ref:- https://stackoverflow.com/a/937965/6305733 
 + 
 +Related commands 
 +<code> 
 +ls -rt *.txt | tail -n5 | tr '\n' '\0' | xargs -0 -i% md5sum % 
 +</code> 
 +==== remove large directories ==== 
 + 
 +Use rsync to delete large directories. 
 + 
 +<code> 
 +mkdir empty_dir 
 +rsync -a --delete empty_dir/    yourdirectory/ 
 +</code> 
 + 
 +As per https://unix.stackexchange.com/questions/37329/efficiently-delete-large-directory-containing-thousands-of-files, it is more efficient than running "rm -rf" or some combination of find + "rm -rf"
 ==== stackoverflow answers I came across ==== ==== stackoverflow answers I came across ====
   * prepend to a file - https://stackoverflow.com/questions/10587615/unix-command-to-prepend-text-to-a-file   * prepend to a file - https://stackoverflow.com/questions/10587615/unix-command-to-prepend-text-to-a-file
Line 33: Line 96:
  
 Found it in | https://stackoverflow.com/questions/16391208/print-a-files-last-modified-date-in-bash Found it in | https://stackoverflow.com/questions/16391208/print-a-files-last-modified-date-in-bash
 +
 +==== tput: unknown terminal "xterm-256color" ====
 +When I moved my miniconda3 installation from /home/rajulocal/miniconda3 to /opt/rajulocal/miniconda3, I started getting
 +<code>
 +tput: unknown terminal "xterm-256color"
 +</code>
 +
 +To fix it, I did
 +<code>
 +conda install --force-reinstall ncurses
 +</code>
 +
 +It turns out that the --fore-reinstall option was important since simply doing
 +<code>
 +conda install ncurses
 +</code>
 +was not installing ncurses as it was already uptodate.
 +
 +Ref:- https://stackoverflow.com/questions/32798940/tput-unknown-terminal-xterm-256color
  
linux_notes.txt · Last modified: 2023/09/24 15:33 by raju