index                              
*   Linux                  
  6/13/20   index                  
                                 
   
  Home special characters http://userwww.service.emory.edu/~kim/psy770u/Reference/special_characters.html
  Install / Fedora
  cronjobs commands   cmd  - <opts>    
  Info (inxi)   cmd  --    no options follow
  Desktops   ie rm --  -Fr           (remove the file named " -Fr ")
  dnf          
  DNS
  firewalld date   date MMDDhhmm   to set the date and time.      
  LVM   date  +%m %m (month)  %d (day)  %y (2-digit year)  %Y (4-digit year)   (no space after the + )
  LVM2    
  N.Neighbor'd fedora setting the time zone >>> cd  /usr/share/zoneinfo/America/ http://technology.mattrude.com/2009/08/setting-the-time-zone-on-fedora-from-the-shell/
  NM   cp  Chicago   /etc/localtime  
  Wireless   note:  nice reference site (and for other stuff too, ie, downloading and installing Fedora , … , …. )
  Services fedora 20 setting the time zone >>> timedatectl  list-timezones http://www.server-world.info/en/note?os=Fedora_20&p=timezone
  Sys Jour   ie timedatectl  set-timezone  Asia/Tokyo  
      timedatectl  status  
       
                   
   
                  month  day
    cat cat   /var/log/secure.log* | grep 'Failed password' | grep sshd | awk '{print $1,$2}' | sort | uniq -c  cat   /var/log/auth.log* | grep 'Failed password' | grep sshd | awk '{print $1,$2}' | sort | uniq -c 
       
       cat   /var/log/secure* | grep 'authentication failure'  | awk '{print $1,$2}' | sort | uniq -c  cat   /var/log/auth.log* | grep 'authentication failure'  | awk '{print $1,$2}' | sort | uniq -c
       
      cat /var/log/secure* | grep 'Failed password' |  sort | uniq -c show failed SSH logins by date (look in all "secure*" files)
      cat /var/log/secure* | grep 'authentication failure' |  sort | uniq -c
       
      cat /var/log/messages.1 | grep 'could not send mail' |  wc -l the number of couldn't email entries
      cat /var/log/messages.1 | grep 'could not send mail' | awk '{print $1,$2}' | sort | uniq -c the number of couldn't email entries by Month and Day
             
   
    chmod chmod u+s  /usr/sbin/hddtemp When the setuid bit is used, the behavior described above it's modified so that when an executable is launched, 
    it does not run with the privileges of the user who launched it, but with that of the file owner instead. 
    https://linuxconfig.org/how-to-use-special-permissions-the-setuid-setgid-and-sticky-bits
   
    du   du -s -k * | sort -n -r   var/adm/messages
      du . var/log/syslog
      du -s * env
       
      du -h  --max-depth=1  /var/log  |  sort -rh  | head  -4
      du -h  --max-depth=1  /var/www/html   |  sort -rh  | head  -5
      du -h  --max-depth=1  /home   |  sort -rh  | head  -6
       
    Getting the Size of a Directory  
    df df -hT human readable and Type
      df -k      (df -h)  
             
   
    find   find  .    -name  '*log*'    -type f    -mtime +700    -exec rm {}  \;
      find  /var/spool/mqueue   -name  '*log*'    -type f    -mtime  +700    -exec rm {}  \;
       
      find  .   -name  mdh   -type d     (dir)  
      find  /   -name socket.py  -type f  
       
        find   /home/users   -name   .mailrc   -type f   -print
   
    grep   http://www.panix.com/~elflord/unix/grep.html#wildcards
       
    "escape sequence" \  "take the next char literally" rm  -rf    one\\dir
       
      grep -v  ' \ - \ - ' uses escape sequence
       
      grep -v  '\-\-' throw out lines with -- in them.
      grep   ora*    *.log find ora in all log files
      grep  "  478  "      *.txt find  <space 478 space>  in all .txt files
             
   
             
    .gz files gunzip  file.gz uncompress .gz files https://www.cyberciti.biz/faq/howto-compress-expand-gz-files/
      gunzip  /var/log/*.gz uncompress all log files
       
    tar.gz tar xvzf file.tar.gz gunzip < file.tar.gz | tar xvf -
      tar xvzf file.tgz gunzip < file.tgz | tar xvf -
             
   
    ls -l  /dev/disk/by-uuid
    lsblk   umount /dev/sdb1   Mounting USB drives and FLASH drives
    mount mkdir /mnt/TFLASH  (FreeAgent)  
      mount -t ntfs-3g /dev/sdb1 /mnt/TFLASH  
    foxconn >  mount  /dev/sdf1  /mnt/FreeAgent mount a  "ext 4" usb drive                >>>>>>>>>> had to uplug, then plug  back in.
       
      # dmesg <enter>  
       
    fdisk fdisk  -l list
       
    mkfs.ext4 mkfs.ext4 /dev/sdb1 format to a  ext4  file system http://ksearch.wordpress.com/2010/09/29/format-usb-in-linux/
       
             
   
    lscpu display CPU info, such as Architecture
   
    snapshot ls -alR > file
   
    links ln -s   from   to symbolic       linkname       actual path/name
   
    ksh changing the hist file HISTFILE=$HOME/.history_$$
   
   
    ssh   ssh  -P 8267   192.168.1.67
      ssh  -P 8268   192.168.1.68
         
   
    terms   <cnt> <alt>  F1     (thru F6)  
               <alt>  F7     (return to desktop)  
       
    putting text to a term echo "some text"  >  /dev/pts/1  
           
   
   
    install new software   yum list    
    yum list  "*WORD*"  
    yum install  PACKAGE installs PACKAGE from the List
         
   
    tilde stuff  ~   ~/                   go to my home dir
      ~username      go to usernames home dir
     
   
   
    CDROM stuff
    find out who is using the cdrom
        1. get lsof and run it list open files
        2.  run fuser -c  /cdrom     or file user
                  fuser -c  /cdrom/cdrom0     (whichever appropiate to the mount opint)
   
    solutions to release the cdrom
        1.  run fuser -ck  /cdrom   or
                  fuser -ck  /cdrom/cdrom0
        2.  kill vold and restart it
   
     check for any "dead" processess, "D or Z" when using "ps axf"
   
    /etc/init.d/volmgt stop If you need to access a floppy or CDROM special device, you may need to turn off the volume manager.
    /etc/init.d/volmgt start To turn the volume manager back on
   
      Mount, copy, and extract CD-ROM content from an IBM proc.
      cd /tmp  
      mount  -v  cdrfs  -o  ro  /dev/cd0   /mnt  
      cp  /mnt/*   /tmp/  
      umount   /mnt    
   
   
   
    Floppy stuff very likely you'll need to use rcp vs. cp to get the file you want onto the floppy disk.
   
    vold &
    volcheck -v
    cd /floppy/floppy0
    eject   (cd out of the floppy directory first)
   
   
    while [ 1 ] ; do After Power Outage
    date restart:
    ls -l Apache
    sleep 60 Samba
    done mount:
    ^ c to exit FreeAgent
   
    cd /var/log
    tail -fn0 syslog  kern.log debug Monitoring files in real-time from the command-line.
   
   
   
    Misc Stuff
   
    Linux Backup  ----->  Timeshift
    lspci |  grep  -i  eth (-i  ignore case)
    last show logins listed in the /var/log/wtmp  file
   
    fail2ban-client ping check if fail2ban is working (server should respond with "pong")
   
   
    echo "a snails progress." | mail -v -s snailmessage  [email protected]
   
    echo `date` | mail -v -s mess3   [email protected]
   
    mail -v -s "some progress"   [email protected]  <  /home/mdh/test-mail.txt
   
   
    $ sudo crontab -e    
    #trim the eMMC once a week
    15 0 0 * *      /sbin/fstrim / >/dev/null 2>&1
   
    Part 3: 2>&1 file descriptor                  
      >i>  
    Whenever you execute a program, the operating system always opens three files STDIN, STDOUT, and STDERR as we know   
      whenever a file is opened, operating system (from kernel) returns a non-negative integer called the File Descriptor.   
    So 2>&1 simply says redirect STDERR to STDOUT The file descriptor for these files are 0, 1, 2 respectively.  
       
    & means whatever follows is a file descriptor, not a filename.  
       
    In short, by using this command you are telling your program not to shout while executing.  
       
    What is the importance of using 2>&1?  
       
    If you want to produce no output even in case of some error produced in the terminal. To explain more clearly, let's consider the following example:  
       
    $ ls -l > /dev/null  
    For the above command, no output was printed in the terminal, but what if this command produces an error:  
       
    $ ls -l file_doesnot_exists > /dev/null   
    ls: cannot access file_doesnot_exists: No such file or directory  
    Despite I'm redirecting output to /dev/null, it is printed in the terminal. It is because we are not redirecting error output to /dev/null, so in order to redirect error output as well, it is required to add  2>&1
       
    $ ls -l file_doesnot_exists > /dev/null 2>&1  
                           
   
    How-To run a command that will survive terminal close >   https://unix.stackexchange.com/questions/4004/how-can-i-run-a-command-which-will-survive-terminal-close
       
      $ nohup redshift &  
      $ nohup redshift >/dev/null 2>&1  & ??  
       
      $ redshift &  
      $ disown  
                       
   
    Rsync
   
    "zero out a mailbox"     ie cat   /dev/null    /var/spool/mail/root
      /var/spool/mail/ ie cat   /dev/null  >  chrishassell
      cat   /dev/null  > " _____.log"  
       
    "implied device null" clearing out a file cp > wtmpx
      cp   /dev/null    wtmpx
         > /dev/null  2> /dev/null