xxxxxxxxxx
aptitude -v -v moo
aptitude -vv moo
xxxxxxxxxx
1.sudo // meaning superUser do give access to superuser work
sudo -h // gives the command help
2.pwd // meaning path of working directory
pwd <options(-L or -P)> // -L gives path to logical path and -P for physical path
//-L For example,if existing in a dir /home/symlinked, it's a symlink to /home/realdir; it would display /home/symlinked.
//-P For example, if existing in a dir /home/symlinked, it's a symlink to /home/realdir; it would display /home/realdir.
3.cd <options(~[username] or .. or -)>
4.ls <options (-R or -a or -lh)>//-R recursive, -a means all including hidden files
//-lh shows the file size with easy readable format
5.cat // meaning conacat used to conacat files
cat filename.txt // view the file
cat > filename.txt // creates a new file and ctrl+D to save the file
cat file1.txt file2.txt > file3.txt // merges two files
tac filename.txt // display content of file in reverse order
6.cp // to copy the files and directories
cp filename.txt destinationPath
cp filename.txt /home/username/Documents
cp filename1.txt filename2.txt filename3.txt /home/username/Documents
cp filename1.txt filename2.txt // copy content of file in another file
cp -R /home/username/documents /home/username/documents_backup
// -R copy everything recursively meaning copy whole directory
7.mv // primary use is to move and rename files and directories
mv filename.txt /home/username/Documents // moves file to this directory
mv old_filename.txt new_filename.txt // renames the filename
8.mkdir // used for creating one or many directries at once and set permission
// for each one of them
mkdir [options] directory_name
mkdir Music // create a directory called Music
mkdir Music/Songs // create a directory inside Music
mkdir -p Anime/Movies // create multiple parent directories if needed
mkdir -m a=rwx [directories] // read and write and execution access
mkdir -v [directories] // verbose meaning print statement for each directory created
9.rmdir // removes empty directory but user must have sudo privilage in parent directory
rmdir folder_name
rmdir -p Anime/Movies //if both directores are empty we can delete both by using this flag
10.rm //this command is used to delete files in the directory
// user performing this command must have write permission
rm [options] filename.txt
rm file1.txt file2.txt file3.txt // removes multiple files
rm -i file1.txt file2.txt file3.txt // prompts for confirmation before deleting file
rm -r directoryname/ // remvoes file recursively
rm -f file1.txt file2.txt file3.txt // removes file without any confirmation
11.touch // this allows you to create empty file or to modify time stamp
touch filename.txt // for creating file
touch filename{1..3}.txt // create multiple file filename1.txt, filename2.txt, filename3.txt
touch -a filename.txt // changes access time to currenttime
touch -m filename.txt // chagnes modified time to currenttime
touch -a -t YYYYMMDDhhmm.ss filename.txt// this will set the acess time as per provided
touch file1.txt -r file2.txt // this will copy access and modified time of file2.txt and update in file1.txt
touch -d '8 Mar' filename.txt // this will set the give string as date and rest will be same as current time
touch -d '20:10' filename.txt // this will se the time and rest will be same current date
12. stat filname.txt // gives access, modified and created time data etc
13.locate // will help to find the file with the name
locate filename.txt
locate -i school // will find all filenames having school word in it
// -i ignores the case
locate -i school*notes // finds all files with containing words school and notes
14.find // to find file or directory with directory path to look for
find [directory] -name [filename]
find /home -name notes.txt // will find notes.txt in home directory and its sub folder
find -name notes.txt //will find notes.txt in current directory
find ./ type d -name directoryname // will find the directory with name
15.grep // to find some data in the file
grep [options] pattern [FILE]
grep -A2 pattern file_name // print 2 more lines after the pattern match
grep -B2 pattern file_name // print 2 lines before the pattern match
grep -C3 pattern file_name // print 3 lines before and after the patten match
options:
-i // case insensative search
-w // search for words only
-c // counts the total matches
-r // search in recursive pattern
-n // prints lines numbers
-v //this options show the reverse match i.e which don't match
grep pattern file1, file2, file3
grep pattern * // search in the all present files
grep 'query1\|query2' file // serarching for multiple queryies at a time
egrep 'query1|query2' file
grep -e query1 -e query2 file
grep -E 'query1|query2' file
grep '^query' file // search the lines which starts with query
grep '^query1.*query2$' file // finds lines which starts with query1 and endswith query2
xxxxxxxxxx
sysadmin@localhost:~$ aptitude moo
There are no Easter Eggs in this program.
xxxxxxxxxx
sysadmin@localhost:~$ ls
Desktop Documents Downloads Music Pictures Public Templates Videos
xxxxxxxxxx
sysadmin@localhost:~$ ls Documents
School alpha-second.txt food.txt linux.txt os.csv
Work alpha-third.txt hello.sh longfile.txt people.csv
adjectives.txt alpha.txt hidden.txt newhome.txt profile.txt
alpha-first.txt animals.txt letters.txt numbers.txt red.txt
xxxxxxxxxx
sysadmin@localhost:~$ aptitude moo
There are no Easter Eggs in this program.
xxxxxxxxxx
sysadmin@localhost:~$ ls -l
total 32
drwx------ 2 sysadmin sysadmin 4096 Dec 20 2017 Desktop
drwx------ 4 sysadmin sysadmin 4096 Dec 20 2017 Documents
drwx------ 2 sysadmin sysadmin 4096 Dec 20 2017 Downloads
drwx------ 2 sysadmin sysadmin 4096 Dec 20 2017 Music
drwx------ 2 sysadmin sysadmin 4096 Dec 20 2017 Pictures
drwx------ 2 sysadmin sysadmin 4096 Dec 20 2017 Public
drwx------ 2 sysadmin sysadmin 4096 Dec 20 2017 Templates
drwx------ 2 sysadmin sysadmin 4096 Dec 20 2017 Videos
xxxxxxxxxx
sysadmin@localhost:~$ ls -r
Videos Templates Public Pictures Music Downloads Documents Desktop
xxxxxxxxxx
sysadmin@localhost:~$ ls -l -r
total 32
drwx------ 2 sysadmin sysadmin 4096 Dec 20 2017 Videos
drwx------ 2 sysadmin sysadmin 4096 Dec 20 2017 Templates
drwx------ 2 sysadmin sysadmin 4096 Dec 20 2017 Public
drwx------ 2 sysadmin sysadmin 4096 Dec 20 2017 Pictures
drwx------ 2 sysadmin sysadmin 4096 Dec 20 2017 Music
drwx------ 2 sysadmin sysadmin 4096 Dec 20 2017 Downloads
drwx------ 4 sysadmin sysadmin 4096 Dec 20 2017 Documents
drwx------ 2 sysadmin sysadmin 4096 Dec 20 2017 Desktop
sysadmin@localhost:~$ ls -rl
total 32
drwx------ 2 sysadmin sysadmin 4096 Dec 20 2017 Videos
drwx------ 2 sysadmin sysadmin 4096 Dec 20 2017 Templates
drwx------ 2 sysadmin sysadmin 4096 Dec 20 2017 Public
drwx------ 2 sysadmin sysadmin 4096 Dec 20 2017 Pictures
drwx------ 2 sysadmin sysadmin 4096 Dec 20 2017 Music
drwx------ 2 sysadmin sysadmin 4096 Dec 20 2017 Downloads
drwx------ 4 sysadmin sysadmin 4096 Dec 20 2017 Documents
drwx------ 2 sysadmin sysadmin 4096 Dec 20 2017 Desktop