Skip to main content

Posts

How to give access to user on linux server?

  How to create the local account on the linux server? create the local account only in case when server is not domain joined. # realm list   :this command will show you if the server has been domain joined or not. # useradd -g <groupname>  -s/bin/bash   -c "comment for user"  -m  -d   /home/<username> <username> # passwd  <username> # chage -d  0  <username>  : it will allow user to change the password after first login.  # chage -1 <username>  # id <username> †***************************************† How to give the access to user on the domain joined server ? # id <username> # realm list :check if the server has been added to domain or not. #add the user to the WH group in Active directory. # id <username> : check if the user has become part of WH group or not. # cat/etc/group : check which group is there allready created for the admins.(ex admins). # usermod  -aG  <groupname>  <username> # cat  /etc/group :

Access Control List

  Access control list : What is ACL? • It provides an additional, more flexible permission mechanism for file systems. It is designed to assist with UNIX file permissions. ACL allows you to give permissions for any user or group to any disc resource. Use of ACL : • Think of the scenario in which particular user is not the member of the group created by you but still you want to give some read or wite access how can you do it without making user the member of the group here comes in picture ACL, ACL helps us to do this trick. •basically ACLs are used to make the flexible permission mechanism in Linux. from Linux man pages ACLS are used to define more fine grained discretionary access rights for files and directories. •commands to assign and remove ACL permissions are:  setfacl  and  getfacl List of the commands for setting up ACL: 1. to add permission for user: setfacl -m u:user:rwx  /path of file 2. To add permission for the group: setfacl -m g:group:rw   /path of file 3. To allow all

Monitor and manage the processes

  Monitor and manage the processes: df:  report the filesystem disk space usage. df -h output format:  filesystem: size: used: available: use %: mounted on du:  estimate the file space usage. du/:  list all the files present in the/with its size. du-k/  list the files in/and its size in kb du-k/1sort-ar | more:  lists the files inside the / with its size in KB sorts the output with highest size on the top and lists the output one page at a time. du-h | sort-ar | more:  lists the files inside the / with its size in human readable format sorts the output with highest size on the top and lists the output one page at a time.  df-hT:  lists the filesystem and shows the filesystem type and gives the size in human readable format. uptime:  tells you how long the system is running. top:  display the linux processes. free:  this command gives the information about your memory. free-m:  gives the memory size in megabyte. Isof:  list open files. tcpdump:  It is used to capture, filter, and analyz

Scheduling the future linux tasks through Crontab

  Scheduling the future linux tasks through Crontab: export EDITOR=vi to specify a editor to open crontab file. crontab -e: Edit crontab file, or create one if it doesn't already exist. crontab -l : crontab list of cronjobs, display crontab file contents. crontab -r :Remove your crontab file. crontab -v :Display the last time you edited your crontab file. (This option is only available on a few systems.) ....................................................  Syntax of the Cron jobs: * * * * *script/command first * : minute (0-59) second* : hour (0-23) third *: day of the month (1-31) fourth *: Month of the year (1-12) fifth* : day of the week (0-6): 0 represents sunday. .........,..............................  A line in crontab file like below removes the tmp files from /home/someuser/tmp each day at 6:30 PM. 30 18 * * * rm /home/someuser/tmp/* Cronjob runnig everyhour: 00 * * * *  rm/home/someuser/tmp/ cron every hour to run at 15 minute of an hour.. 15 * * * * rm /home/someus

Cockpit

  Cockpit : Cockpit is the server administration tool sponsered by redhat focused on providing a modern looking and user friendly interface to manage and administrator servers. cockpit is the easy-to-use, integrated, glanceable, and open web-based interface for your servers. The application is available in most of the linux distribution such as centos, redhat, ubuntu and fedora. It is installed in redhat 8 by default and it is optional in version 7. It can monitor system resources, add or remove accounts, monitor system usage shut down the system and perform quite a few other tasks all through a very accessible web connection Install, configure and manage cockpit : 1. Ensure internet is working in linux server. 2.  yum install cockpit-y:  install cockpit I 3. systemctl enable cockpit : enable at boot. 4.  systemctl start cockpit  :start the service S.  systemctl status cockpit : check the status of the cockpit service. 6.  https://192.168.1.12:9090 : access the cockpit web interface.

Transfer files through SCP

  SCP: Secure transfer protocol. It helps to transfer computer files securely from the local to remote host. It is somewhat similar to File transfer protocol but it adds secunty and authentication. Protocol : set of rules used by computers to communicate. Default SCP port: port 22 same as ssh. Question : how to transfer file using SCP? For this lecture we again need 2 linux machines: client:  myfirstlinuxvm server:  linuxcentos7 1. Login to client machine as yourself 2. go to home directory 3.  touch jack  :create the file called jack 4. open the file jack and put some content in there. 5.  scp jack jaime@192.168.1.58:/home/jaime:  login to server as jaime and transfer the jack file to server in home/jaime location.  6.login to server and check if the file jack has been transferred or not.

Transfer files through FTP

  FTP : Its a standard network protocol used for the transfer of computer files between a client and server on the computer network. FTP is built on a client-server model architecture using separate control and data connections between client and the server. protocol : Set of rules used by computers to communicate default FTP port: 21 in this lecture we need 2 linux vms: client: myfirstlinuxvm server: linuxcentos7 login to server linuxcentos7 : 1.become root . 2 rpm -qa| grep vsftpd : check if the ftp is installed or not 3. ping www.google.com : check if internet is working or not in the server. 4. yum install vsftpd: install ftp package if not installed. 5. rpm -qa | grep vsftpd: check if the ftp is installed or not. 6. cd /etc/vsftpd : go to vsftpd folder in etc directory. 7. l s -Itr: list out the content of vsftpd folder. (we need vsftpd.conf file). 8. cp -p vsftpd.conf vsftpd.conf.org: take the backup of the vsftpd.conf file. 9.vi vsftpd.conf: edit the file and make the following

Post build configurations on Redhat VM

  ************************************* Post build configuration on Linux VM: ************************************* Set the hostname. hostnamectl set-hostname <Servername> ***************************************** Network configuration : Make sure VM gets the ipv4 ip address either from DHCP or assign the static ip address to it.   Question : How to assign the static ip address to the linux machine using the nmcli ?  Answer: fire the below commands: nmcli device nmcli connection modify enpos3 ipv4.addresses 10.253.1.34/24 nmcli connection modify enpos3 ipv4.gateway 10.253.1.1 nmcli connection modify enpos3 ipv4.method manual nmcli connection modify enpos3 ipv4.dns 8.8.8.8 nmli connection down enpos3 nmcli connection up enpos3 ip address show enpos3 nmcli connection show ************************†****************** Register to RHΝ. Register to redhat network if the linux vm is redhat vm. subscription-manager register --org <org>  --activationkey <activation key> --force

Shell Scripting basics

  Shell: Its like a container. interface between users and kernal / OS. CLI is a shell Find your shell: echo $0 : gives the output which shell you are using. cat /etc/shells: gives the output of available shells. your shell?  /etc/passwd .................................  Shell Scripting: What is shell Script? Shell Script is the executable file containing multiple shell commands that are executed sequentially. The file can contain: 1. shell 2. comments 3. commands 4. statements shell script should have executable permissions. shell script has to be called absolute path. if it is called from the current location then, ./script.sh .....................................  Shell Script-Basic Scripts: Question : Write the script to print "hello world" on the terminal. Answer: content of script1.sh should be: #!/bin/bash  echo Hello World chmod a+x script1.sh: give the executible permission to all for this script. /script1.sh : run the script. ....,......................  Question

Linux Interview Questions 2024 .

  Theoretical  questions : 1. What is Linux ? 2.What is the history of Linux ? 3.difference between linux and unix ? 4.what is linux kernel ?Is it legal to edit the linux kernel? 5.what is shell? 6.what is LILO? 7.What is GUI? 8.what are the examples of shell used in linux ? 9.what is swap space in linux ? 10.what commands can be used to check how much memory is being used by linux OS? 11.what is maximum length of filename under linux ? 12.Explain the file permissions in linux . 13.what is inode? 14. what is process id ? 15. what is lvm ? 16.what are the directory related commands in Linux ? 17. what are the daemons? 18. what are the process states ? 19.explain grep command in linux . 20.Explain the ls command in linux . 21.Explain the redirection operator in linux. 22.what is the tar command used for ? 23. If you want to list the entries that start with the character ‘a’ in  particular file , what would be the command ? cat file1.txt | grep ^a .  24.what are the minimum number of disk

Most used commands in Linux.

  Commands in Linux are utilities that allow users to perform basic and advanced tasks on the operating system. These commands are executed on the Linux terminal, which provides a command-line interface for users to interact with the system. The terminal in Linux is similar to the command prompt in Windows OS. It's worth noting that the commands in Linux are case-sensitive, and users must be careful with the spelling and capitalization of the commands they enter. Whenever you want a quick reference, just review the below table: Command Usage ls Lists the content of a directory alias Define or display aliases unalias Remove  alias  definitions pwd Prints the working directory cd Changes directory cp Copies files and directories rm Remove files and directories mv Moves (renames) files and directories mkdir Creates directories man Displays manual page of other commands touch Creates empty files chmod Changes file permissions ./ Runs an executable exit Exits the current shell session s