Loading....
ls ,cd , pwd , vi, gedit, cp,mv,rm,pico,touch
history
cat -n (-n line number)
>> or 2> save to file the output
script and scriptreplay command like videoplayer you can record the code uyou write to terminal.
$ script -t 2> timing.log -a output.session
type commands;
…
..
exit
$ scriptreplay timing.log output.session
find /home/muslum -name "*.php" finds php files
-iname ignore case sensitive
-path search path
-regex : $ find . -regex ".*\(\.py\|\.sh\)$"
using more condition:
new.txt some.jpg text.pdf
$ find . \( -name "*.txt" -o -name "*.pdf" \) -print
./text.pdf
./new.txt
find by file ( access time - time, modification time -mtime , change time -ctime ) -ctime +7 means before 7 day ago
search based on file size
-delete : deleting matched files
serach based on permission (755) and ownership
$ find . -type f -name "*.php" !-perm 644 -print
$ find . -type f -user slynux -print
exec chown username {} changes file owner change can be done by a mathes
serach -prune ignore matches
xargs
output | tr 'find text' 'replace text'
tr -d delete option
For example:
$ echo "Hello 123 world 456" | tr -d '0-9'
Hello world
tr -s
echo "ddddd 432 ddsa dd" | tr -s 'dd '
output : "d432 dsa d"
Checksum and Varification
$ md5deep -rl directory_path > directory.md5
# -r to enable recursive traversal
# -l for using relative path. By default it writes absolute file path in
output
Alternately, use a combination of find to calculate checksums recursively:
$ find directory_path -type f -print0 | xargs -0 md5sum >> directory.md5
To verify, use the following
Cryptographic tool and Hashes
cript , gpg, base64, md5sum, sha1sum, opensslpasswd
Sorting unique and dublicates
commands: sort ,uniq
sorting file content in alpha,numeric,reverse,merge sorted, and unique
sorting according to key and column
# Sort reverse by column1
$ sort -nrk 1 data.txt
4 linux 1000
3 bsd 1000
2 winxp 4000
1 mac 2000
# -nr means numeric and reverse
spliting file and data
you can spli5t files by matches and based on its content data, extension
split ,csplit
$ split [COMMAND_ARGS] PREFIX
$ csplit server.log /SERVER/ -n 2 -s {*} -f server -b "d.log" ; rm
server00.log
$ ls
server01.log server02.log server03.log server.log
based on extension
he name from name.extension can be easily extracted using the % operator. You can
extract the name from "sample.jpg" as follows:
file_jpg="sample.jpg"
name=${file_jpg%.*}
echo File name is: $name
The output is:
File name is: sample
The next task is to extract the extension of a file from its filename. The extension can be
extracted using the # operator as follows:
Extract .jpg from the filename stored in the variable file_jpg as follows:
extension=${file_jpg#*.}
echo Extension is: jpg
The output is:
Extension is: jpg
Rename
Renaming *.JPG to *.jpg:
$ rename *.JPG *.jpg
To replace space in the filenames with the "_" character:
$ rename 's/ /_/g' *
# 's/ /_/g' is the replacement part in the filename and * is the wildcard for the
target files. It can be *.txt or any other wildcard pattern.
To convert any filename of files from uppercase to lowercase and vice versa:
$ rename 'y/A-Z/a-z/' *
$ rename 'y/a-z/A-Z/' *
To recursively move all the .mp3 files to a given directory:
$ find path -type f -name "*.mp3" -exec mv {} target_dir \;
To recursively rename all the files by replacing space with the "_" character:
$ find path -type f -exec rename 's/ /_/g' {} \;
spell check and dictionary manipulation
grep , look, aspell list
$ look word filepath
Or alternately, use:
$ grep "^word" filepath
Automating interactive input
Making commands quicker by running parallel processes
Last Update: Posted by: müslüm ÇEN