Labels

View file content with terminal

# cat file1
view the contents of a file starting from the first row [man]

# head -2 file1
view first two lines of a file [man]

# less file1
similar to 'more' command but which allows backward movement in the file as well as forward movement [man]

# more file1
view content of a file along [man]

# tac file1
view the contents of a file starting from the last line [man]

# tail -2 file1
view last two lines of a file [man]

# tail -f /var/log/messages
view in real time what is added to a file [man]
READ MORE - View file content with terminal

Users and Groups

# chage -E 2005-12-31 user1
set deadline for user password [man]

# groupadd [group]
create a new group [man]

# groupdel [group]
delete a group [man]

# groupmod -n moon sun
rename a group from moon to sun [man]

# grpck
check correct syntax and file format of '/etc/group' and groups existence [man]

# newgrp - [group]
log into a new group to change default group of newly created files [man]

# passwd
change password [man]

# passwd user1
change a user password (only by root) [man]

# pwck
check correct syntax and file format of '/etc/passwd' and users existence [man]

# useradd -c "User Linux" -g admin -d /home/user1 -s /bin/bash user1
create a new user "user1" belongs "admin" group [man]

# useradd user1
create a new user [man]

# userdel -r user1
delete a user ( '-r' eliminates home directory) [man]

# usermod -c "User FTP" -g system -d /ftp/user1 -s /bin/nologin user1
change user attributes as description, group and other [man]
READ MORE - Users and Groups

Text Manipulation with commandline

# cat example.txt | awk 'NR%2==1'
remove all even lines from example.txt [man]

# echo a b c | awk '{print $1}'
view the first column of a line [man]

# echo a b c | awk '{print $1,$3}'
view the first and third column of a line [man]

# cat -n file1
number row of a file [man]

# comm -1 file1 file2
compare contents of two files by deleting only unique lines from 'file1' [man]

# comm -2 file1 file2
compare contents of two files by deleting only unique lines from 'file2' [man]

# comm -3 file1 file2
compare contents of two files by deleting only the lines that appear on both files [man]

# diff file1 file2
find differences between two files [man]

# grep Aug /var/log/messages
look up words "Aug" on file '/var/log/messages' [man]

# grep ^Aug /var/log/messages
look up words that begin with "Aug" on file '/var/log/messages' [man]

# grep [0-9] /var/log/messages
select from file '/var/log/messages' all lines that contain numbers [man]

# grep Aug -R /var/log/*
search string "Aug" at directory '/var/log' and below [man]

# paste file1 file2
merging contents of two files for columns [man]

# paste -d '+' file1 file2
merging contents of two files for columns with '+' delimiter on the center [man]

# sdiff file1 file2
find differences between two files and merge interactively alike "diff" [man]

# sed 's/string1/string2/g' example.txt
replace "string1" with "string2" in example.txt [man]

# sed '/^$/d' example.txt
remove all blank lines from example.txt [man]

# sed '/ *#/d; /^$/d' example.txt
remove comments and blank lines from example.txt [man]

# sed -e '1d' exampe.txt
eliminates the first line from file example.txt [man]

# sed -n '/string1/p'
view only lines that contain the word "string1" [man]

# sed -e 's/ *$//' example.txt
remove empty characters at the end of each row [man]

# sed -e 's/string1//g' example.txt
remove only the word "string1" from text and leave intact all [man]

# sed -n '1,5p' example.txt
print from 1th to 5th row of example.txt [man]

# sed -n '5p;5q' example.txt
print row number 5 of example.txt [man]

# sed -e 's/00*/0/g' example.txt
replace more zeros with a single zero [man]

# sort file1 file2
sort contents of two files [man]

# sort file1 file2 | uniq
sort contents of two files omitting lines repeated [man]

# sort file1 file2 | uniq -u
sort contents of two files by viewing only unique line [man]

# sort file1 file2 | uniq -d
sort contents of two files by viewing only duplicate line [man]

# echo 'word' | tr '[:lower:]' '[:upper:]'
convert from lower case in upper case [man]
READ MORE - Text Manipulation with commandline

System information

# arch
show architecture of machine(1) [man]

# cal 2011
show the timetable of 2011 [man]

# cat /proc/cpuinfo
show information CPU info [man]

# cat /proc/interrupts
show interrupts [man]

# cat /proc/meminfo
verify memory use [man]

# cat /proc/swaps
show file(s) swap [man]

# cat /proc/version
show version of the kernel [man]

# cat /proc/net/dev
show network adpters and statistics [man]

# cat /proc/mounts
show mounted file system(s) [man]

# clock -w
save date changes on BIOS [man]

# date
show system date [man]

# date 041217002007.00
set date and time - MonthDayhoursMinutesYear.Seconds [man]

# dmidecode -q
show hardware system components - (SMBIOS / DMI) [man]

# hdparm -i /dev/hda
displays the characteristics of a hard-disk [man]

# hdparm -tT /dev/sda
perform test reading on a hard-disk [man]

# lspci -tv
display PCI devices [man]

# lsusb -tv
show USB devices [man]

# uname -m
show architecture of machine(2) [man]

# uname -r
show used kernel version [man]
READ MORE - System information