Ad Code

Responsive Advertisement

Ticker

6/recent/ticker-posts

LINUX-Pro

 Types of available:


*date: shows the current data & time

$ date

Mon Dec 25 22:16:37 IST 2023

uptime: shows the current uptime 
* uptime
22:18:19 up 13 days,  8:15,  0 users,  load average: 1.56, 0.92, 0.65

*$ whoami
whoami
webmaster

**finger: display about the user info
**user/id: show user information
*man --> manual of commands
*username: shows yours username
*who/w display who is online
-------------------------------------Read a file-------------------------
ls -- list a directory
cat filename: view a filename
less filename: it will show the files in page wise two go for next page we need to type space in keyboard
more filename: 15% of file to view
head -> will give the first 10 lines of code
if you want first 20 lines of code
head -20 filename
tail -20 filename it will give the last 20lines of code

------------------create a file----------------
touch : it will create a file with zero bytes
cat > filename :  it will create a file same time allow us to write content on that file
nano : create a file if does not exist
vi : create a file if does not exist
rm : remove a file
mkdir : create a directory
rmdir : remove a empty directory
rm -rf : remove a directory forcefully 

create a multiple file/folders
touch file1 file2 file3
mkdir  folder1 folder2 folder3
----------------------Managing files and directories----------------------------------
cp : used for copy a file

cp source-file destination-file (it will use only for files if u want cope a folder use below)
cp -R source-folder1 dest-folder2

mv : move a file & we can use rename file aswell
mv source-file destination-file
find : find a file

find / -option filename
find / -name file1

grep: search a pattern in a file
grep pattern filename
grep raj filename
grep -i (it will ignore the case sensitive)
ls -l | grep filename
* search for only folder
ls -l | grep ^d (starting with d letter)
$ ls -la | grep ^d
drwxr-xr-x 1 shiva 197609       0 Dec 21 18:52 ./
drwxr-xr-x 1 shiva 197609       0 Jan 21  2022 ../
drwxr-xr-x 1 shiva 197609       0 Dec 15 00:33 .VirtualBox/
drwxr-xr-x 1 shiva 197609       0 Aug 11  2022 .aws/
drwxr-xr-x 1 shiva 197609       0 Sep 15 12:58 .azure/
drwxr-xr-x 1 shiva 197609       0 Jun 23  2023 .azure-kubectl/
drwxr-xr-x 1 shiva 197609       0 Jun 23  2023 .azure-kubelogin/
drwxr-xr-x 1 shiva 197609       0 Dec 13 16:51 .chocolatey/
drwxr-xr-x 1 shiva 197609       0 Dec 14 12:26 .docker/
drwxr-xr-x 1 shiva 197609       0 Dec 13 22:07 .kube/
drwxr-xr-x 1 shiva 197609       0 Dec 14 12:27 .minikube/
drwxr-xr-x 1 shiva 197609       0 Jun 13  2023 .openshot_qt/
drwxr-xr-x 1 shiva 197609       0 Nov 30 20:02 .ssh/
drwxr-xr-x 1 shiva 197609       0 Jun 10  2023 .vscode/
drwxr-xr-x 1 shiva 197609       0 Jan 21  2022 3D Objects/
drwxr-xr-x 1 shiva 197609       0 Jan 21  2022 AppData/
drwxr-xr-x 1 shiva 197609       0 Jan 21  2022 Contacts/
drwxr-xr-x 1 shiva 197609       0 Dec 21 20:16 Desktop/
drwxr-xr-x 1 shiva 197609       0 Dec 13 12:57 Documents/

cd : switch b/w directories
cd ~ To go the home directory

diff: find content diff between files
diff file1 file1
sed: search and replace a particular patterm

sed 's/old_text/new_text/' filename (if the complete word match then only it will replace) it won't update file
sed 's/old_text/new_text/g' filename (if small word is matching also it will replace) it won't update file

sed -i 's/old_text/new_text/' filename --> it will update the file as well
sed -n '5,10p' filename : it will going to display exactly from line number 5 to 10
sed -n '10,20d' filename : it remove those lines  from file & display the rest of content


chmod: change the file permission:

ls -l (to view all perm for files)




symbolic method:
chmod u+x,g-w,o=w filename (user can execute,group will delete write access others have write access)
= means remove all old permission add the one which mentioned in command

Absolute method;
read = 4
write: 2
exec= 1

chmod u=rwx,g=rw,o=r filename (both are same)
chmod 764 filename (both are same)


chown: change the ownership of a file  :
Note: only root have a permission to change the owner ship of a file
chown user:group filename
   
file : shows what kind of a file it is
file filename

------------------------------User management------------------------------------------


cat /etc/passwd (here we can find the all users who part of that machine)
cat /etc/groups (to list the groups)
Create a user:

useradd user1
useradd user2

to setup password to user:
passwd user-name

Add a user to group
useradd -G useraname group-name
To validate
id user-name

*** To allow password based authentication.
vi /etc/ssh/sshd_config 

systemctl restart sshd
-----------------------------System management=============
History:
List of commands executes previously
to get the specific command: !command-number

du -m /foldername (it will display space consumed by mb 's)

which application-name (it shows the path where app installed)





telnet ip-address portnumber
telnet localhost 22

CHKCONFIG: play's good role when system is rebooted to auto restart the app on boot time of server.
chkconfig serive-name on
chkconfig httpd on
Its going to start the application on boot time

To stop:
chkconfig httpd off

systemctl or service both are same
systemctl status httpd
service statis httpd both are same

-------------------------------Process Management-------------------------------------



kill -9 process-id

to get the process id will get in systemctl status httpd


unzip filename.zip
tar -cvf source-tarfile.tar  source-directory

to extarct the directory
tar -xvf source-tarfile.tar (it will extract the tar file)


Softlink:
ln -s sourcefile destfile
using softlink we can reduce the space utilization same file in diff location

hardlink:
the data present in both location if one location we lost also we can find data in another location
ln sourcefile destfile

run a script across the machine

ln -s  /root/original-file-script.sh /usr/local/bin/myscript

validate : ls -l /usr/local/bin

in linux now any where if you type: myscript the script will work




scp sourceserver-filename dest-server-user-name@dest-ipaddress:dest-folder

 What is the booting Process of Linux?

What is OS: OS is a set of programs or modules that control or co-ordinates the hardware resourses for diff application programme. OS is the mediator b/w user/application & hardware OS MOdules: 1.File System Management 2.Process Management 3.Memory Management 4.Device Management 5.Network Management #######TO Get the Kernal version: raj [ ~ ]$ uname -r 5.10.102.2-microsoft-standard ##Boot loader is the special process invoked by you BIOS to load the complete image of your os into Memory User SPace: Kernal Space 1.User login to the centos/rhel as root 1.Kernal will be running 2.Executing any commands or running any application 2. Kernal always will be in protected mode 3.Process are running on u space have low priority 3.Process are ruuning in kernal space as high priority compare to kernal process **to find the path location of package raj [ ~ ]$ whereis git && which git (both commands are same) git: /usr/bin/git raj [ ~ ]$ whereis python python: /usr/bin/python /opt/ansible/bin/python /opt/blobxfer/bin/python **Ways to communicate from user to kernal 1.Linux commands 2.System Calls 3.Proc File System 4.IOCTl 5 sys File System 6.Interupts & signals ############Linux users############### In Linux we have mainly devided 3 types of users 1.root --- > Super user 2.Normal User : Rajesh & Mahesh 3.System user -> ftp, mail, cups Hardlink: Create a files called file1 ls file1 rajharden (Create a link b/w the files) now if u save some data in file1 it will auto saved saved in rajharden file as well raj [ ~/test ]$ cat >> file1 singam hjsbdkf ^C raj [ ~/test ]$ cat file1 singam hjsbdkf raj [ ~/test ]$ cat rajharden singam hjsbdkf ls -li (to files hardlinks by using ls command at 106498 ) aj [ ~/test ]$ ls -li 106498 -rw-r--r-- 2 raj raj 15 May 24 06:30 file1 106498 -rw-r--r-- 2 raj raj 15 May 24 06:30 rajharden ** hardlink only for files ** in hard link if you delete the parent file called file1 still you can access u r data from rajharden raj [ ~/test ]$ rm -rf file1 raj [ ~/test ]$ ls rajharden raj [ ~/test ]$ cat rajharden singam hjsbdkf **************Soft link also called symbolic :- it will indicate like softlinktest -> file2 raj [ ~/test ]$ ln -s file2 softlinktest raj [ ~/test ]$ ls -li total 0 106500 -rw-r--r-- 1 raj raj 0 May 24 06:33 file2 106501 lrwxrwxrwx 1 raj raj 5 May 24 06:33 softlinktest -> file2 In softlink if you remove the parent the softlink file also will be lost raj [ ~/test ]$ rm -rf file2 raj [ ~/test ]$ ls softlinktest raj [ ~/test ]$ cat softlinktest cat: softlinktest: No such file or directory It will supports directories ln -s directoryname filename ``` | Soft Links | Hard Links | |-------------------------------|-------------------------------| | Also known as symbolic | Point directly to the | | links supports both file & directpry | physical file in the file | | | system | |-------------------------------|-------------------------------| | They are pointers to | They are directory entries | | another file | that point to the same | | | inode as the original file | |-------------------------------|-------------------------------| | If the original file is | If the original file is | | deleted or moved, the soft | deleted, the hard link | | link becomes broken | still points to the | | | original file until all | | | hard links are removed | |-------------------------------|-------------------------------| | Soft links can point to | Hard links cannot cross | | directories | file systems | |-------------------------------|-------------------------------| | They can be created across | Hard links are restricted | | file systems | to the same file system | |-------------------------------|-------------------------------| | They use filenames to | They use inodes to link | | reference files | files | |-------------------------------|-------------------------------| | Soft links can have | Hard links cannot have | | different file permissions | different file permissions | | from the original file | from the original file | ``` 3. Hard Link - ln 1. Hardlink - is always created for the files not for the directory 2. whenever you create hard link,new inode is not allocated, the same inode is used 3. Hardlink cannot be created across partition 4.Soft Link - ln -s 1. Softlink = can be created both for the normal file as well directory 2. Whenever you create a soft link ,a new inode is always allocated 3. Softlink can be created across partition To find the which linux we have in os raj [ ~ ]$ echo $SHELL /bin/bash Shell is the Interface b/w user application & kernal raj [ ~ ]$ ps PID TTY TIME CMD 1159 pts/1 00:00:00 bash 2199 pts/1 00:00:00 ps raj [ ~ ]$ echo $$ ----------------> it will give the shell process id echo $$ 1159 ############PROC################ All process infomation will be there in the folder of Proc if you want to see the child process that are running under parent process Example: raj [ / ]$ cd proc/ raj [ /proc ]$ ls 1 1173 37 cgroups devices filesystems irq kmsg locks mtrr softirqs thread-self vmallocinfo 1119 17 60 cmdline diskstats fs kallsyms kpagecgroup meminfo net stat timer_list vmstat 1154 23 acpi consoles dma interrupts kcore kpagecount misc pagetypeinfo swaps tty zoneinfo 1156 2335 buddyinfo cpuinfo driver iomem keys kpageflags modules partitions sys uptime 1159 30 bus crypto execdomains ioports key-users loadavg mounts self sysvipc version raj [ /proc ]$ cd 1154/ raj [ /proc/1154 ]$ ls arch_status clear_refs cpuset fd map_files mounts oom_adj personality smaps statm timers attr cmdline cwd fdinfo maps mountstats oom_score projid_map smaps_rollup status timerslack_ns auxv comm environ gid_map mem net oom_score_adj root stack syscall uid_map cgroup coredump_filter exe limits mountinfo ns pagemap setgroups stat task wchan file /foldername --> it wll tell you the type of file like exec or directory ------------------Linux supports 7 types of files--------------------------- 1.Normal & white files --> touch, cat , echo , vi , head , less , > , nano 2.Directory --> mkdir 3.Hardlink --> ln 4.softlink(symbolic link) --> ls -s 5.Pipe file /Fifo file --> mkfifo 6.character device file or block device file --> mknod 7.socket file --> mksoc ****to get the directory using ls raj [ ~ ]$ ls -la | grep ^d drwxr-xr-x 2 raj raj 4096 Apr 17 17:52 ansible drwx------ 5 raj raj 4096 Apr 17 16:20 .azure *Stat will give the complete info about file or folder raj [ ~/test ]$ stat file2 File: file2 Size: 0 Blocks: 0 IO Block: 4096 regular empty file Device: 700h/1792d Inode: 106498 Links: 1 Access: (0644/-rw-r--r--) Uid: ( 9527/ raj) Gid: ( 9527/ raj) Access: 2024-05-24 06:37:49.716379430 +0000 Modify: 2024-05-24 06:37:42.881414949 +0000 Change: 2024-05-24 06:37:42.881414949 +0000 Birth: 2024-05-24 06:37:42.881414949 +0000 ##########################5.Pipe file /Fifo file --> mkfifo###################### special type of files will be there under /dev those will be used for communicating the devices under dev all buffered files will be there #############################Most widely important commands############################### ls,date,who,whoami,calendar, tar,gzip,(gzip2, Bzip2), tr, cp , my ,rm , mkdir ,rmdir, rm -f sed,awk , cut,paste, find ,grep , test , chmod,chown,chgrp , ping , ssh , rsync, man ,info, aprpos, Network: path: /etc/network/interfaces or /etc/sysconfig/network-scripts/ifcfg-* netstat, nmap,traceroute, arp, head ,tail ,df ,fdisk , mount,umount, fsck , mkfs.ext3, mkfs.ntfs kill, strace, ptrace , lsblk ####################File System######################### File system is a software which is part of OS that will take care of any operations into file Create a file create the directory Permission & directory reading a file & deleting a file TYpes: EXT3,EXT4,EXT5, Reiser FS windows VFAT, NTFS 65 types of linux can support alll file system windows doesn't understarbd the ext5 file sysstem Linux OS --> VFS (Virtual File System) Name | Description --------------------|------------------------------------------------------------ / | Root directory - the top of the file system hierarchy /bin | Essential binary executables (common commands like ls, cp) most of the commands files will be in bin directory /boot | Files needed to boot the system (kernel, boot loader files)uname -r (get the kernal version) /dev | Device files representing hardware and peripherals /etc | System configuration files & dependency configuration files all the configuration file will be in ETC /home | User home directories /lib | Essential shared libraries and kernel modules it will contain all system librariesgvx /media | Mount points for removable media (USB drives, CDs) /mnt | Temporary mount points for mounting file systems /opt | Optional application software packages database related or any other application related /proc | Virtual file system providing process and kernel information & stores the info about proocess id's /root | Home directory of the root user /run | Run-time variable data (system information since last boot) /sbin | System binaries (essential commands for system administration) /srv | Data for services provided by the system (web server data) /sys | Virtual file system providing device and kernel information /tmp | Temporary files /usr | Secondary hierarchy for read-only user data (applications, libraries, documentation) librarries of yum packages /usr/bin | Non-essential binary executables for user commands /usr/lib | Non-essential shared libraries /usr/local | User-provided applications and data /var | Variable data files (logs, databases, websites) /home | For the users who logged in it acts as workspace. ** Kernal path cd /usr/lib/modules 0-999 all allocated to system users after all users aligned to normal users raj [ ~ ]$ id uid=9527(raj) gid=9527(raj) groups=9527(raj) cat /etc/passwd --> list of all users to view the users password cat /etc/shadow --> password in deprecated format **To view the types of shells present in linux raj [ ~ ]$ cat /etc/shells /bin/sh /bin/bash /usr/bin/sh /usr/bin/bash /usr/bin/pwsh /usr/bin/zsh /bin/zsh We can see every user by default which shell they can use raj [ ~ ]$ cat /etc/passwd root:x:0:0:root:/root:/bin/bash bin:x:1:1:bin:/dev/null:/bin/false whenever the shell execute any command successfully,the return value is "0" 1,2,3......255 ---- Error value char,int,flat,double,array ...types of varaible #!/bin/bash echo "Enter the value" read var echo $var 3 method to execute the script a. sh first_script.sh b. ./first_script.sh ---> throw an error , chmod +x first_script.sh c. source first_script.sh or . first_script.sh alias k="kubectl" if u want make permanenet change vi .bashrc add alias ** to load again source .bashrc ?------> it will give the exit status of last executed command raj [ ~ ]$ echo $? ---> if the output comes 0 its always success. 0 apart from 1 to 255 all or errors system level configuration files /etc/profile /etc/inputrc /etc/bashrc /etc/DIR_COLORS /etc/profile.d/---- ---- ----------------------- User-level configuration files .bash_profile .bashrc .bash_logout Shell Variables Variables are nothing but ,it is label that assign some value 2 types of variable 1.local variable 2. Environment variable Local variable are those variables which are defined in the local shell itself you cannot make use of the same variable in some other shell,if u still want to use the variable in some other shell then you need to export that variable by using export command bash also has its inbuilt shell variable which we call it as Environment Variables a=10 export a vi first_script.sh #!/bin/bash echo "Enter the value" read var echo $var 3 method to execute the script a. sh first_script.sh b. ./first_script.sh ---> throw an error , chmod +x first_script.sh c. source first_script.sh or . first_script.sh ls -R folderorpathname it will complete info about folder and subfolder or path inside of the data ***ps -ef State of the Process: 1. Running----------------------------------------> R 2. Sleeping or Interruptable sleep---------> S 3. Stopped-----------------------------------> T ---> Ctrl+z to stop the process or u can send SIGSTOP signal kill -19 <pid> 4. Orphan --------------------------------> O 5. Zombie--- Defunc state -------------------------------> Z 6. Daemon - -----------------------------------------> D #######################Package management##############Redhat package management##############Redhat As RPM not fullfiled everything they came up with the yum --> yellow dog modifier yum dnf rpm yum is the primary package management for rhel Yum is front end everything wll be backend as rpm raj [ ~ ]$ rpm -qa filesystem-1.1-20.cm2.x86_64 zlib-1.2.13-2.cm2.x86_64 from rpm to install any package wget gethe package name rpm -ivh example.rpm ########################################SEd################# SED : Stream editor used for file manipulation raj [ ~ ]$ cat /etc/passwd | sed 's/root/raj/' raj:x:0:0:root:/root:/bin/bash raj [ ~ ]$ cat /etc/passwd | sed -e 's/root/raj/ig' --> g means globally i is case sensitive by default all will be small -e is expression # sed syntax: sed [options] 'command' file 1. Print lines matching a pattern -------------------------------- sed -n '/pattern/p' filename # Example: Print lines containing "hello" sed -n '/hello/p' file.txt 2. Replace a string (first occurrence in each line) --------------------------------------------------- sed 's/old_string/new_string/' filename # Example: Replace "apple" with "orange" sed 's/apple/orange/' file.txt 3. Replace a string globally (all occurrences in each line) ----------------------------------------------------------- sed 's/old_string/new_string/g' filename # Example: Replace all occurrences of "apple" with "orange" sed 's/apple/orange/g' file.txt 4. Replace a string and save changes to the file ------------------------------------------------ sed -i 's/old_string/new_string/' filename # Example: Replace "apple" with "orange" and save sed -i 's/apple/orange/' file.txt 5. Delete lines matching a pattern ---------------------------------- sed '/pattern/d' filename # Example: Delete lines containing "hello" sed '/hello/d' file.txt 6. Delete a specific line number -------------------------------- sed 'linenumberd' filename # Example: Delete line 2 sed '2d' file.txt 7. Delete a range of lines -------------------------- sed 'startline,endline d' filename # Example: Delete lines 2 to 4 sed '2,4d' file.txt 8. Insert text before a specific line ------------------------------------- sed 'linenumber i\text' filename # Example: Insert "hello world" before line 3 sed '3i\hello world' file.txt 9. Append text after a specific line ------------------------------------ sed 'linenumber a\text' filename # Example: Append "hello world" after line 3 sed '3a\hello world' file.txt 10. Substitute only on a specific line -------------------------------------- sed 'linenumber s/old_string/new_string/' filename # Example: Replace "apple" with "orange" on line 2 sed '2s/apple/orange/' file.txt 11. Print a specific line number -------------------------------- sed -n 'linenumberp' filename # Example: Print line 3 sed -n '3p' file.txt 12. Print a range of lines -------------------------- sed -n 'startline,endlinep' filename # Example: Print lines 2 to 4 sed -n '2,4p' file.txt 13. Substitute with a captured group ------------------------------------- sed 's/\(old\)_string/new_\1/' filename # Example: Replace "apple_fruit" with "orange_fruit" sed 's/\(apple\)_fruit/orange_\1/' file.txt 14. Multiple commands with -e option ------------------------------------ sed -e 'command1' -e 'command2' filename # Example: Delete line 2 and replace "apple" with "orange" sed -e '2d' -e 's/apple/orange/' file.txt 15. Using sed with a script file -------------------------------- sed -f script.sed filename # script.sed contains sed commands # Example: script.sed # 2d # s/apple/orange/ # Command to run: sed -f script.sed file.txt #####################################################################AWK###################################################### # awk syntax: awk 'pattern {action}' filename 1. Print all lines ------------------ awk '{print}' filename # Example: Print all lines in file.txt awk '{print}' file.txt 2. Print specific fields ------------------------ awk '{print $1, $3}' filename # Example: Print the 1st and 3rd fields awk '{print $1, $3}' file.txt 3. Print lines matching a pattern --------------------------------- awk '/pattern/' filename # Example: Print lines containing "hello" awk '/hello/' file.txt 4. Print line number and content -------------------------------- awk '{print NR, $0}' filename # Example: Print line number and line content awk '{print NR, $0}' file.txt 5. Sum values in a column ------------------------- awk '{sum += $1} END {print sum}' filename # Example: Sum values in the 1st column awk '{sum += $1} END {print sum}' file.txt 6. Calculate average of a column -------------------------------- awk '{sum += $1; count++} END {print sum/count}' filename # Example: Calculate average of values in the 1st column awk '{sum += $1; count++} END {print sum/count}' file.txt 7. Print lines with more than a specific number of fields --------------------------------------------------------- awk 'NF > num' filename # Example: Print lines with more than 3 fields awk 'NF > 3' file.txt 8. Print lines where a field matches a value -------------------------------------------- awk '$1 == "value"' filename # Example: Print lines where the 1st field is "apple" awk '$1 == "apple"' file.txt 9. Print lines where a field is greater than a value ---------------------------------------------------- awk '$1 > value' filename # Example: Print lines where the 1st field is greater than 10 awk '$1 > 10' file.txt 10. Define field separator -------------------------- awk -F 'separator' '{print}' filename # Example: Define comma as field separator and print fields awk -F ',' '{print $1, $2}' file.txt 11. Use a variable ------------------ awk -v var=value '{print var, $1}' filename # Example: Define variable "prefix" and print it with the 1st field awk -v prefix="Item:" '{print prefix, $1}' file.txt 12. Print a range of lines -------------------------- awk 'NR==start, NR==end' filename # Example: Print lines from 2 to 4 awk 'NR==2, NR==4' file.txt 13. Conditional print with an if statement ------------------------------------------ awk '{if ($1 > value) print $0}' filename # Example: Print lines where the 1st field is greater than 10 awk '{if ($1 > 10) print $0}' file.txt 14. Format output ----------------- awk '{printf "Field 1: %s, Field 2: %s\n", $1, $2}' filename # Example: Format output with printf awk '{printf "Field 1: %s, Field 2: %s\n", $1, $2}' file.txt 15. Execute multiple actions ---------------------------- awk '{action1; action2}' filename # Example: Print the 1st field and then the 2nd field awk '{print $1; print $2}' file.txt 16. Use built-in variables (e.g., NR, NF) ----------------------------------------- awk '{print NR, NF, $0}' filename # Example: Print line number, number of fields, and line content awk '{print NR, NF, $0}' file.txt 17. Filter and process with BEGIN and END blocks ------------------------------------------------ awk 'BEGIN {print "Start"} {print $0} END {print "End"}' filename # Example: Print "Start" before processing, then lines, then "End" awk 'BEGIN {print "Start"} {print $0} END {print "End"}' file.txt 18. Use an external script file ------------------------------- awk -f script.awk filename # script.awk contains awk commands # Example: script.awk # {sum += $1} # END {print sum} # Command to run: awk -f script.awk file.txt ########################################################################################################################### # cut syntax: cut [options] filename 1. Cut specific fields by delimiter ----------------------------------- cut -d 'delimiter' -f field_list filename # Example: Cut the 1st and 3rd fields by comma delimiter cut -d ',' -f 1,3 file.txt 2. Cut specific characters by position -------------------------------------- cut -c char_list filename # Example: Cut characters from position 1 to 3 cut -c 1-3 file.txt 3. Cut multiple ranges of characters ------------------------------------ cut -c range1,range2 filename # Example: Cut characters from position 1 to 3 and 5 to 7 cut -c 1-3,5-7 file.txt 4. Cut specific bytes --------------------- cut -b byte_list filename # Example: Cut bytes 1 to 4 cut -b 1-4 file.txt 5. Combine cut with other commands using pipes ---------------------------------------------- command | cut -d 'delimiter' -f field_list # Example: Combine with echo to cut fields from output echo "a,b,c,d" | cut -d ',' -f 2,4 6. Cut fields with tab delimiter (default) ------------------------------------------ cut -f field_list filename # Example: Cut the 1st and 2nd fields (tab-delimited) cut -f 1,2 file.txt 7. Use cut with multiple delimiters (GNU cut) --------------------------------------------- cut --output-delimiter='new_delimiter' -d 'delimiter' -f field_list filename # Example: Replace comma delimiter with semicolon in output cut --output-delimiter=';' -d ',' -f 1,2 file.txt # grep syntax: grep [options] pattern filename 1. Search for a pattern in a file --------------------------------- grep 'pattern' filename # Example: Search for "hello" in file.txt grep 'hello' file.txt 2. Search recursively in directories ------------------------------------ grep -r 'pattern' directory # Example: Search for "hello" in all files in the current directory grep -r 'hello' . 3. Ignore case while searching ------------------------------ grep -i 'pattern' filename # Example: Search for "hello" case-insensitively grep -i 'hello' file.txt 4. Show line numbers of matches ------------------------------- grep -n 'pattern' filename # Example: Search for "hello" and show line numbers grep -n 'hello' file.txt 5. Display count of matching lines ---------------------------------- grep -c 'pattern' filename # Example: Count lines containing "hello" grep -c 'hello' file.txt 6. Invert match to show non-matching lines ------------------------------------------ grep -v 'pattern' filename # Example: Show lines that do not contain "hello" grep -v 'hello' file.txt 7. Search for whole words ------------------------- grep -w 'pattern' filename # Example: Search for whole word "hello" grep -w 'hello' file.txt 8. Use regular expressions for complex patterns ----------------------------------------------- grep -E 'pattern' filename # Example: Search for lines containing "hello" or "world" grep -E 'hello|world' file.txt 9. Print only matched parts of a line ------------------------------------- grep -o 'pattern' filename # Example: Print only the word "hello" from matching lines grep -o 'hello' file.txt 10. Search for multiple patterns -------------------------------- grep -e 'pattern1' -e 'pattern2' filename # Example: Search for "hello" or "world" grep -e 'hello' -e 'world' file.txt 11. Show N lines before and after the match ------------------------------------------- grep -C N 'pattern' filename # Example: Show 2 lines of context around matches grep -C 2 'hello' file.txt 12. Show N lines before the match --------------------------------- grep -B N 'pattern' filename # Example: Show 2 lines before matches grep -B 2 'hello' file.txt 13. Show N lines after the match -------------------------------- grep -A N 'pattern' filename # Example: Show 2 lines after matches grep -A 2 'hello' file.txt 14. Read patterns from a file ----------------------------- grep -f patternfile filename # Example: Search patterns listed in patterns.txt grep -f patterns.txt file.txt 15. Combine grep with other commands using pipes ------------------------------------------------ command | grep 'pattern' # Example: Combine with echo to search for a pattern in output echo "hello world" | grep 'hello' #############################TR############################## command | tr <'old'> <'new'> raj [ ~ ]$ cat /etc/passwd | tr 'root' 'Root' Root:x:0:0:Root:/Root:/bin/bash raj [ ~ ]$ cat /etc/passwd | sort ----> will be used for to arrange in alphabet order bin:x:1:1:bin:/dev/null:/bin/false daemon:x:6:6:Daemon User:/dev/null:/bin/false find . -name "*.pdf" --> find a files in . means current directory / from root directory ====================Network============= ip a ifconfig to add any ip adress to interfaces ip address add ipaddressof traceroute google.com raj [ ~/test ]$ netstat -tnlp ---> What are the ports are running machine (No info could be read for "-p": geteuid()=9527 but you should be root.) Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 127.0.0.1:8888 0.0.0.0:* LISTEN - tcp 0 0 127.0.0.1:50342 0.0.0.0:* LISTEN - tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN - netstat -nutlp | grep httpd nsloopup: The nslookup command is an older edition of the dig command. Also, it is utilized for DNS related problems. raj [ ~/test ]$ nslookup cloudera.com Server: 168.63.129.16 Address: 168.63.129.16#53 Non-authoritative answer: Name: cloudera.com Address: 96.17.180.42 Name: cloudera.com Address: 96.17.180.51 Name: cloudera.com raj [ ~/test ]$ dig cloudera.com ; <<>> DiG 9.16.48 <<>> cloudera.com ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 27976 ;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 1

02.) Could you brief me about the LDAP? 03.) Could you let me know something about "chage" command? 04.) Could you tell me about XEN? 05.) Could you let me know how we can change the default permissions of a user? What is the default permission of a user on a file. 06.) Could you tell me that when we are creating a partition now a days in our linux then what type of format we are using over there. like, filesystem using there..? 07.) What is SWAP? 08.) What is the usage of /bin directory? 09.) If I am installing a custom software like, VLC Media Player or Any Microsoft Office. Then in which directory it goes ?? /tmp /bin /opt /usr 10.) Could you tell me the full form of GRUB? 11.) Could you tell me about the "grep" command? 12.) Could you tell me something about "AWK" command? 13.) Could you tell me about what is the booting process? 14.) Could you tell me how we can change the owner of any particular file? 15.) What command we can use to change the permission of any file? 16.) let's take a example we have a file having 640 permission => means for owner we have 6(read,write) group 4(read) and for other 0(none). I have to give a special permission to A1 user that it can read my file. So, How can i provide that permission? 17.) Could you tell me something about GRUB? what is GRUB? 18.) Give information about XEN server how it works.. which is used for Virtualization technology? 19.) What is Port Forwarding? 20.) Could you tell me something about IPTables ?? 21.) Could you give me some information about SAMBA Server? 22.) Which protocol was in background when we are transferring the files from linux to windows OR windows to linux? 23.) Could you tell me something about DNS? 24.) What is init runlevels? init-3 is used for what? init-4? 25.) What is NTP Server and how it works? 26.) What is NFS Server? 27.) Could you tell me something about XEN server? 28.) Could you tell me something about the "SED" command? 29.) What is the full form of SED command? 30.) Could you tell me about the DNS Server? 31.) Records of DNS? 32.) How we can compress our data in linux? What command we use to compress the data in Linux? 33.) What is the full form of tar? 34.) If I want to change the group of a user. Which command is use to change it? 35.) When you create a user then which file contains the password of that user? 36.) Which file contains the details of the user? 37.) What is the UID(User ID) of root user? 38.) From where users UID Start? 39.) What is the tcp wrappers? 40.) What is the IP Tables? and how the IP Tables are used? 41.) Could you tell me something about the booting process of linux? how linux boot? 42.) How we can set policies on users or group? let's take a example we have a file having 640 permission => means for owner we have 6(read,write) group 4(read) and for other 0(none). I have to give a special permission to A1 user that it can read my file. So, How can i provide that permission? 43.) Could you tell me something about the virtualization? 44.) If I discuss about the security in linux we use Ip Tables. what are the IP Tables? 45.) How many types of editors in Linux? Could you name any three editors ? 46.) What is the full form of VI? 47.) Could you tell me something about the NFS Server? 48.) Could you tell me something about the GREP command? 49.) cd - ==> What is the usage of this command? 50.) How we can create multiple directory (means directory inside a directory) using a single command? e.g /abcd/1 to 10/a-z 51.) AWS ==> Could you tell me something about the versioning feature of S3? 52.) Could you give me the detailed information about VI Editor? 53.) How could I forcefully save a file? 54.) How to cut a line in VI Editor? 55.) How to search for a word in VI Editor? 56.) Could you tell me something about the NFS Server? 57.) Do you know anything about VI Editor? 58.) How do I cut a line from a file in VI Editor? 59.) How to save a file in VI Editor? 60.) Could you tell me something about the init runlevels? 61.) What is the name of our linux bootloader? and where it is located in our linux operating system? 62.) Could you tell me the working of /sbin directory? 63.) What is YUM? 64.) What is the full form of YUM? 65.) Could you tell me something about the user's ID? How many types of users are there?and what UID they are having? 66.) Normal User UID starts from? 67.) Could you tell me something about the Virtualization using XEN? 68.) What is GPT and MBR? 69.) Could you explain about SAMBA Server? 70.) Could you explain about NTP Server? 71.) Could you tell me something about the Virtualization technology using XEN? 72.) Could you tell me something about ACL (Access Control List) in files and Directories? 73.) [root@localhost ~]# [user@localhost ~]$ ==> What it specifies? 74.) How could you get help in linux? If you want to take help of any command how you get it? 75.) What is grep command? 76.) If I have to search the exact word in grep then what type of option should I use over there? 77.) If I have to count how many lines are there which is matching the string What option should I use there to count the no. of lines in grep? 78.) What is Pipe | How pipe symbols is used? 79.) If I say that I am sharing a file from linux to windows OR window to linux. Which type of protocol or server should I use into it? 80.) Which protocol is used behind the SAMBA Server? 81.) Could you tell me something about the groups? If I have created a group so which file changes? Where it reflected that you have created a group? 82.) What is the Primary Group and Secondary Group of a USer? 83.) How to take backup of any file and Directory? 84.) Do you know anything about the security of Linux? How we can secure the Linux Operating System? Firewall, TCP wrapper, IP Tables & SE-Linux. 85.) What types of connections in firewalls we have? 86.) What is SUDO command? 87.) Could you tell me how the Linux Boot? 88.) How we can configure Quota on a File System? 89.) Could you tell me something about SUDO? 90.) What is RPM? How to install a package using RPM? 91.) What is YUM? 92.) Could you tell me something about the NFS Server? 93.) What is ACL? How to set ACL permission to a particular user for a file? 94.) Init runlevel-1? Why runlevel-1 is used? What we do with single user-mode? 95.) What is the main configuration file of GRUB? From which we can secure the password of grub? Where it is located? 96.) What is LVM? 97.) What is KVM? 98.) What is SE-Linux? 99.) What is SE-Linux? For what it is used for? 100.) How we can schedule any task in linux? 101.) If I have to schedule the task at evening 6:30 PM per day. Then what will be the syntax which you have to write in the crontab? 102.) If I have to check all the users login in our system. So which log file we have to open to check all users login specifications in which log file we used to get? 103.) Could you tell me about KVM, XEN Server or Virtualization? 104.) What is LVM? What it does? How it works? 105.) What is the difference between LVM and Normal Partition Which you have created. 106.) Could you define about RAID Level-5? 107.) What is RAID-1? 108.) What is SUDO? From where we can configure any user to use SUDO in DOS System? 109.) What is grep command? 110.) find command is used for? 111.) From which command we can take the backup of any file and Directory? 112.) When we create a user, which file contains the user information as well as the password information? 113.) What is init runlevels? Why runlevel 5 is used? 114.) Could you tell me something about the XEN Server or KVM Server? 115.) Could you tell me something about the PAM (Plugable Authentication Module). What is PAM? Why we are using this module? 116.) Why IP Tables are used? 117.) What is the Port No. Of NFS? 118.) Could you tell me something about the RAID? 119.) What command we have to use to increase the LVM space? 120.) You have created a Standard Partition (i.e, /dev/sd7) Now you need to format it. What command you will use to format that partition? Which filesystem you will use to format it? 121.) Which command you use to see how many partitions has been created? 122.) Which command is used to check how much disk usage has been done in our directory? How much disk usage is doing by our directory? 123.) What command use to check the disk free? 124.) Which file I am going to edit the permanently mount the file system? 125.) Could you tell me something about NFS Server? On Which Port No it works on? 126.) Could you tell me something about ACL (Access Control List) in linux? 127.) What is Port Forwarding? 128.) What is SE-Linux? 129.) Could you give the detail information to create partition in our system? 130.) How to format the disk? 131.) Could you tell me about the linux booting process? How linux machine boot?
Show less


Post a Comment

0 Comments

Ad Code

Responsive Advertisement