shell comando ls code example

Example 1: bash commands

ls	ls       -   Lists files in current directory
ls -alF	     -   List in long format
cd	         - change directory
cd tempdir   - Change directory to tempdir
cd..         - Move back one directory
mkdir        - Make a directory
rmdir        - Remove directory(Must be empty)
cp           - Copy File into Directory
rm           - Remove or Delete File
rm *.tmp     - Remove all file
mv           - Move or rename files
more         - Look at file, one page at a time
lpr          - Send file to printer
man          - Online help about command
passwd       - Change password
gzip         - Compress file
grep<str><files> - Find which files contain certain word
who          - Lists who is logged on your machine
history      - Lists command history
date         - Print out current date
whoami       - returns your username
pwd          - tell where currently you are

Example 2: linux list

# syntax
# ls *<options> '*<file-dir>'

# example 
ls -ltr './*.log'

# + --------- + -------------------------------------------------------+
# | OPTION    |  DESCRIPTION                                           |
# + --------- + -------------------------------------------------------+
# | -a        | list all files including hidden file starting with '.' |
# | --color   | colored list [=always/never/auto]                      |
# | -d        | list directories - with ' */'                          |
# | -F        | add one char of */=>@| to enteries                     |
# | -i        | list file's inode index number                         |
# | -l        | list with long format - show permissions               |
# | -la       | list long format including hidden files                |
# | -lh       | list long format with readable file size               |
# | -ls       | list with long format with file size                   |
# | -r        | list in reverse order                                  |
# | -R        | list recursively directory tree                        |
# | -s        | list file size                                         |
# | -S        | sort by file size                                      |
# | -t        | sort by time & date                                    |
# | -X        | sort by extension name                                 |
# + --------- + -------------------------------------------------------+