Open Source is king!



linux system administration commands

Best Linux File Editor


  • Vim: A potent text editor with a lot of customization options is called vim( Vi Improved). Despite its steep learning curve, it has many advanced features, such as a wide variety of editing commands, plugin support, and extensive customization options.
  • Emacs: Another robust text editor with a ton of features. Code editing, text formatting, file management, and more are just a few of the features it offers. The scripting language( Emacs Lisp), which is unique to eMacs, enables extensive extension and customization.
  • Nano: Many Linux distributions come pre-installed with Nano, a straightforward and user-friendly text editor. For beginners or users who prefer a more straightforward editing experience, it is an excellent option because of its simplicity of use and user interface.
  • Popular proprietary text editor, Sublime Text is renowned for its speed and adaptability. Numerous features, such as split editing, multiple cursors, syntax highlighting, and a thriving ecosystem of plugins and themes, are available.
  • Microsoft created the free source code editor Visual Studio Code( VS Code). With features like intelligent code completion, debugging, version control integration, and a sizable ecosystem of extensions, it offers an excellent editing experience.

İntroduction to vi Editor in Linux


Linux Vim Editor

  • In the Linux and Unix operating systems, vi is a potent and widely utilized text editor. It is well-known for its effectiveness and adaptability and has been around since the early days of Unix. System administrators, programmers, and advanced users who work primarily from the command line frequently choose vi because it runs in a terminal environment and doesn’t rely on graphical user interfaces.

What is the Difference Between Vi and Vim in Linux ?


  • Vim, which offers more features and functionality, is essentially an expanded and improved version of Vi. It is generally advised to use Vim if Vi is available on a Linux system because it has more features and an improved editing experience. For those who need to work in an environment that is strictly Vi-compatible or who prefer a lightweight, minimalistic editor, Vi is still an option.

İmprove vim Skills in Linux



sed Command in Linux


Sed Command Linux


Sed Command Linux

Sed Command Linux

Sed Command Linux

What is User Management in Linux ?


useradd USERNAME
passwd USERNAME 
visudo 
usermod -aG wheel USERNAME
su USERNAME -
groups 
sudo whoami 

cat /etc/paswd Linux

useradd -m -d /var/www/user3 -s /bin/bash -c " extra information" -U user3 

useradd -m -d /var/www/phpdeveloper -s /bin/zsh -c php developer" -u 1000 -g 1000 phpdeveloper 

useradd -m -d /var/www/flask -s /usr/sbin/nologin -c "turhansofttech flask developer" -u 1019 flask 

useradd -m -d /var/www/user -k /etc/custom.skell -s /bin/tcsh -c "No Active Member 
of turhansofttech" -u 1027 user

 useradd -M -N -r -s /bin/false -c "Disabled turhansofttech Member" djangodeveloper



useradd username 
passwd username 
useradd -d /home/newusers turhansofttech     #directory /path/to/file
cat /etc/passwd | grep turhansofttech
useradd -u 999 user 
cat /etc/passwd | grep user
useradd -u 1000 -g  500 phpdeveloper
cat /etc/passwd | grep phpdeveloper 

useradd -G devops,webdev,linuxsys turhansofttech
id turhansofttech

useradd -M admin1
ls -l /home/admin1

useradd -e 2025-02-12 webdeveloper 
chage -l webdeveloper 

useradd -e 2024-03-23 -f 30 frontend

useradd -c "Linux system administrator" linux 
tail -1 /etc/passwd 

useradd -s /sbin/nologin user2 
tail -1 /etc/passwd 

User Management Linux

User Management Linux

User Management Linux

User Management Linux

User Management Linux

User Management Linux

User Management Linux

User Management Linux

User Management Linux

User Management Linux

User Management Linux



The /etc/login.def FİLE


etc/login.defs linux

The “chage” Command in Linux


chage command linux

How to switch to sudo user in Linux ?


sudo user linux

Monitor Users Commands in Linux


who 
who -a 
who -b 
who -l 
who -m
who -r
who -u
who -q
last reboot

Monitor User Commands

Monitor User Commands

Monitor User Commands

Monitor User Commands

User to User Communication in Linux


User to User Communication in Linux

User to User Communication in Linux

Linux Ldap Authentication Active Directory etc.


Linux LDAP Authenctication

Difference between Active Directory , LDAP , IDM , WindBIND

  • Active Directory is a Windows-based directory service for managing network resources, LDAP is a protocol for accessing directory services, IDM is a comprehensive identity management solution, and Winbind enables integration between Linux/Unix systems and Active Directory. These technologies can be used together or independently, depending on the specific requirements of an organization’s network environment.

System İnformation Utility Command in Linux


System İnformation Utility Command in Linux

Processes and Jobs in Linux


Process and Jobs in Linux

Processes and Jobs in Linux


Linux Service, Process, thread

Process / Services Commands



systemctl Command in Linux


systemctl 
systemctl status firewalld.service 
systemctl stop firewalld.service 
systemctl status firewalld.service
systemctl disable firewalld
systemctl status firewalld.service

systemctl list-units 
systemctl list-units --all

systemctl linux command

“ps” Command


ps linux command

“top” Command


top linux command

“kill” Command


linux kill command

“crontab” Command


  • Users of Linux and Unix-like operating systems can create, edit, and manage their cron jobs using the command-line utility Crontab.

* * * * *
| | | | |
| | | | +----- Day of the Week (0 - 7) (Sunday = 0 or 7)
| | | +------- Month (1 - 12)
| | +--------- Day of the Month (1 - 31)
| +----------- Hour (0 - 23)
+------------- Minute (0 - 59)


Command Description
crontab -eEdit the current user’s crontab file using the default text editor.
crontab -lDisplay the contents of the current user’s crontab file
crontab -rRemove the current user’s crontab file.
crontab -iPrompt for confirmation before removing the crontab file.
crontab -vDisplay the last time you edited your crontab file (This option only available on a few systems.)

Crontab Example


  • 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/*

Crontab File Location


  • Mac OS X
    • /usr/lib/cron/tabs/
  • BSD Unix
    • /var/cron/tabs
  • Solaris, HP-UX , Debian, Ubuntu
    • /var/spool/cron/crontabs/
  • AIX , Red Hat Linux , Centos , Fedora
    • /var/spool/cron/

Crontab Environment


  • Cron invokes the command from the user’s HOME directory with the shell (/usr/bin/sh) cron supplies a default environment for every, shell defining.

HOME=user's-home-directory
LOGNAME=user's-login-id
PATH=/usr/bin:/usr/sbin:.
SHELL=/usr/bin/sh

Disable Email


  • By default cron jobs sends a email to the user account executing the cronjob. If this is not needed put the following command At the end of the cron job line.

>/dev/null 2>&1

Generate Log File


30 18 * * * rm /home/someuser/tmp/* > /home/someuser/cronlogs/clean_tmp_dir.log

MinHourDay/MonthMonthDay/WeekExecution Time
30011,6,12*– 00:30 Hrs on 1st of Jan, June & De.
020*101-5-8.00 PM every weekday (Mon, Fri) only in Oct.
001,10,15**– Midnight on 1 st, 10th & 15 th of month
5,10010*1At 12.05, 12.10 every Monday & on 10th of every month


“at” Command


linux at command

linux at command

Additional Cron Jobs


cd /etc 
ls -l cron .*

Additonal Cron Jobs Linux



System Monitoring


System Monitoring

System Monitoring

top
df
dmesg
iostat 1
netstat
free
cat /proc/info 
cat /proc/meminfo

Log Monitoring


cd /var/log
ls -l boot.log
more cron 
cat dmesg     #su - sudo su root 
more maillog 
more secure
tail -f secure
more messages 
grep -i error messages   #su - or sudo su root account 
ls -l | grep chrony

Log Monitoring

System Maintenance Commands


System Maintenance Commands

Changing System Hostname


Changing System Hostname

Changing System Hostname

Finding System İnformation and Architecture


uname -s
uname -n 
uname -r
uname -v
uname -m
uname -p
uname -i 
uname -o

Finding System İnformation and Architecture

Finding System İnformation and Architecture


Terminal Commands


Terminal Commands

How to Reset root Password in Linux


  1. In the boot grub menu select option to edit
  2. Select Option to edit (e)
  3. Go to the line = ro and change it with rw init=/sysroot/bin/sh
  4. Now press Control+x to start on single user mode
  5. Now access the system with this command ( chroot /sysroot )
  6. Reset the Password ( passwd root )
  7. Exit chroot ( exit )
  8. Reboot your system ( reboot )

How to Reset root Password in Linux


How to Reset root Password in Linux


How to Reset root Password in Linux


How to Reset root Password in Linux


How to Reset root Password in Linux

Method 2 :


How to Reset root Password in Linux

How to Reset root Password in Linux

How to Reset root Password in Linux



SOS Report


Sos Report Linux

Sos Report Linux

Sos Report Linux


Environment Varibles


printenv 
printenv | more 
env 
find /  -perm  /6000 

Environment Varibles

Environment Varibles

Environment Varibles

Environment Varibles




Special Permissions with setuid , setgid , and sticky bit

  • Setting the setuid permission:

chmod u+s filename

  • Setting the setgid permission:

chmod g+s filename

  • This command sets the sticky bit on the specified directory. Only the owner of a file within this directory can delete or rename the file, even if other users have write permissions on the directory.
  • The specified file, filename, is given the setgid permission by this command. Instead of using the user’s primary group, the file will be executed under group ownership.

chmod +t directory