Linux Commands Day 2
history > history1.txt Output: store all the previous command in .txt
man cat
cat file1 file2 cat file1 file2 > file3
man ls
ls -l (user, group and others) Output:
ls -lh display file size in easy to read format. i.e i.e M for MB, K for KB, G for GB
ls -lt sort the file names displayed in the order of last modification time.You will be finding it handy to use it in combination with -l option.
wildcards wildcards are interpreted by the shell and the results are returned to the command you run. There are three main wildcards in Linux: An asterisk (*) – matches one or more occurrences of any character, including no character. Question mark (?) – represents or matches a single occurrence of any character. Bracketed characters ([ ]) – matches any occurrence of character enclosed in the square brackets. It is possible to use different types of characters (alphanumeric characters): numbers, letters, other special characters etc.
ls -x chap*, ls -x chap??, ls -x chap? Output:
ls -x chap[123], ls -x chap[1-4]
wc history, ls | wc Output:
count="ls -l", $count
echo $count, echo $msg
echo $msg Output:
echo 'The avg pay is $100'
man cp
cp file1 file2
file *
df -H Df: This manual page documents the GNU version of df. df displays the amount of disk space available on the file system containing each file name argument. Syntax: df [OPTION] [FILE]
df -h Output:
du -hs folder, tty, uname -r Output:
man grep, inode grep: grep searches for PATTERNS in each FILE. PATTERNS is one or more patterns separated by newline characters, and grep prints each line that matches a pattern. Typically PATTERNS should be quoted when grep is used in a shell command Syntax: grep [OPTION...] PATTERNS [FILE...] grep [OPTION...] -e PATTERNS ... [FILE...] grep [OPTION...] -f PATTERN_FILE ... [FILE...] inode: Each file has an inode containing metadata about the file. An application can retrieve this metadata using stat(2) (or related calls), which returns a stat structure, or statx(2), which returns a statx structure.
grep -c "unix" grepfile
grep "^unix" grepfile
grep -o "unix" grepfile
grep uni grepfile
grep unix grepfile
grep -i "UNix" grepfile
grep -c "unix" grepfile
grep "^unix" grepfile
grep -w "unix" grepfile, grep -o "unix" grepfile Output:
grep -n "unix" grepfile, grep -v "unix" grepfile Output:
grep "^unix" grepfile, grep "os.$" grepfile Output:
ps
ps , ps -eman ps : ps displays information about a selection of the active processes. Syntax: ps [options] Output:
ps -ef
man kill, kill -9 process_id
help, exit, sudo poweroff

linux commands such as ls cd grep and other useful commands