1. 1. Introduction
    1. 1.1. Workshop Day1
    2. 1.2. Workshop Day2
    3. 1.3. Workshop Day3
    4. 1.4. Workshop Day4
    5. 1.5. Workshop Day5
    6. 1.6. Workshop Day6
    7. 1.7. Workshop Day7
    8. 1.8. Workshop Day8
    9. 1.9. Workshop Day9
  2. 2. Cheatsheets
    1. 2.1. User Management
    2. 2.2. Ubuntu Package Managers
    3. 2.3. Redhat Package Manager - YUM
    4. 2.4. Redhat Package Manager - RPM
    5. 2.5. Vi Editor
    6. 2.6. find command
    7. 2.7. sed command
    8. 2.8. grep command
    9. 2.9. common commands
  3. 3. QnA
  4. About me!

Linux Essentials Training

cp command

To copy a file

cp ~/Desktop/foo.txt ~/Downloads/foo.txt

To copy a directory

cp -r ~/Desktop/cruise_pics/ ~/Pictures/

To create a copy but ask to overwrite if the destination file already exists

cp -i ~/Desktop/foo.txt ~/Documents/foo.txt

To create a backup file with date

cp foo.txt{,."$(date +%Y%m%d-%H%M%S)"}

cat command

To display the contents of a file

cat <file>

To display file contents with line numbers

cat -n <file>

To display file contents with line numbers (blank lines excluded)

cat -b <file>

tee command

To tee stdout to

ls | tee <outfile>

To tee stdout and append to

ls | tee -a <outfile>

To tee stdout to the terminal, and also pipe it into another program for further processing

ls | tee /dev/tty | xargs printf "\033[1;34m%s\033[m\n"

sort command

To sort a file

sort <file>

To sort a file by keeping only unique

sort -u <file>

To sort a file and reverse the result

sort -r <file>

To sort a file randomly

sort -R <file>