0% found this document useful (0 votes)
12 views6 pages

User and Group Management Commands Configura On Files: o o o o

Uploaded by

Linda Gacha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views6 pages

User and Group Management Commands Configura On Files: o o o o

Uploaded by

Linda Gacha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

User and Group Management Commands

 Configura on Files:

o /etc/passwd: Stores user account informa on.

o /etc/shadow: Stores secure user password data.

o /etc/group: Stores group informa on.

o /etc/skel/: Template directory for new user home directories.

1. User Commands:

o useradd ahmed: Add a new user ahmed.

o passwd ahmed: Set a password for ahmed.

o id ahmed: Display UID, GID, and group memberships for ahmed.

o Op ons:

 -c "comment": Add a comment for the user.

 -d /home/custom: Set custom home directory.

 -e YYYY-MM-DD: Set account expira on date.

 -f days: Set days before account deac va on a er password expires.

 -g GID: Assign primary group.

 -G groups: Assign secondary groups.

 -m: Create home directory.

 -M: Do not create home directory.

 -s shell: Set default shell.

 -u UID: Assign specific UID.

2. Modify User:

o usermod -s /bin/tcsh ahmed: Change login shell.

o usermod -c "Ahmed Ingénieur réseau" ahmed: Change user comment.

o Op ons:

 -g group: Change primary group.

 -G groups: Add to secondary groups.

 -a -G groups: Append to exis ng groups.

 -l newname: Change username.

 -L: Lock user account.

 -U: Unlock user account.

3. Delete User:
o userdel -r ahmed: Delete user and their home directory.

4. Group Management:

o groupadd -g 1090 developpeur: Create a group with GID 1090.

o groupmod -n developpeur-web -g 1100 developpeur: Rename and change GID.

o groupdel developpeur-web: Delete group.

5. Password and Expira on:

o passwd -d ahmed: Remove user password.

o passwd -e ahmed: Force password change on next login.

o passwd -l ahmed: Lock user account.

o passwd -u ahmed: Unlock user account.

o chage -E YYYY-MM-DD ahmed: Set account expira on date.

o chage -l ahmed: List password aging informa on.

o Op ons:

 -d lastday: Set last password change date.

 -m days: Minimum password age.

 -M days: Maximum password age.

 -W days: Warning before expira on.

Scheduling Jobs

 Configura on Files:

o /etc/crontab: System crontab.

o /etc/cron.allow and /etc/cron.deny: Restrict cron access.

o /var/spool/cron/: Directory for user crontabs.

1. One- me Jobs with at:

o at now +5 minutes: Schedule a job 5 minutes from now.

o at> command: Enter command to schedule.

o Op ons:

 -c: Print job commands.

 -d or atrm ID: Delete job by ID.

 -l or atq: List user’s pending jobs.

 -m: Send email on comple on.

2. Recurring Jobs with cron:


o crontab -e: Edit user’s crontab.

o crontab -l: List user’s current crontab.

o crontab -r: Remove user’s current crontab.

o Crontab Syntax:

 0 10 * * * /home/user/script.sh: Run daily at 10:00.

 */20 * * * * /home/user/script.sh: Run every 20 minutes.

 15 08 * * 1 /home/user/script.sh: Run at 08:15 on Mondays.

3. Systemd Timers:

o systemctl enable < mer-unit-name>. mer: Enable a mer.

o systemctl start < mer-unit-name>. mer: Start a mer immediately.

o Timer Op ons:

 OnCalendar=*-*-* 08:30:00: Schedule daily at 08:30.

 OnAc veSec=2m: Run 2 minutes a er ac va on.

 systemctl list- mers: List ac ve mers.

Localiza on and Interna onaliza on

1. Time and Date:

o medatectl: View system me and date.

o tzselect: Choose me zone.

o cat /etc/ mezone: Display me zone.

o date: Show current date and me.

2. Locale Se ngs:

o echo $LANG: Display current locale.

o cat /etc/locale.conf: Display system-wide locale configura on.

o locale: Show all locale variables.

3. Character Encoding:

o iconv -f ISO-8859-1 -t UTF-8 file.txt > converted.txt: Convert text encoding.

Networking Files & U li es

 Configura on Files:

o /etc/hostname: Contains the system’s hostname.


o /etc/hosts: Maps IP addresses to hostnames.

o /etc/nsswitch.conf: Configures name resolu on order (e.g., files, DNS).

o /etc/resolv.conf: Specifies DNS servers for domain name resolu on.

Common Networking Commands

1. General Interface Commands:

o ifconfig: Display ac ve network interfaces.

o ifconfig -a: Display all network interfaces, including inac ve ones.

o sudo ifconfig eth0 192.168.1.1 netmask 255.255.255.224 broadcast 192.168.1.31: Set IP, netmask, and
broadcast on eth0.

o ifconfig eth0 down && ifconfig eth0 up: Disable and re-enable eth0.

o ifconfig 10.17.32.28/22 up: Ac vate interface with IP 10.17.32.28 and subnet mask /22.

o ifdown eth0 && ifup eth0: Restart the eth0 interface.

2. NetworkManager Commands:

o nmcli general: Show general networking status.

o nmcli device wifi list: List available Wi-Fi networks.

o nmcli connec on show: Show all saved network connec ons.

o nmcli connec on down "Hotel Internet": Disconnect from "Hotel Internet".

o nmcli device disconnect "Hotel Internet": Disconnect device from "Hotel Internet".

o nmcli device wifi connect "Hotel Internet": Connect to Wi-Fi "Hotel Internet".

o nmcli connec on delete "Hotel Internet": Delete saved network profile for "Hotel Internet".

o nmtui: Text-based user interface for managing NetworkManager.

3. Hostname Management:

o hostname: Display the current hostname.

o hostnamectl set-hostname storage: Change hostname to "storage".

o hostnamectl status: View the current hostname and related system informa on.

IP Commands for Address and Route Management

1. Address and Link Commands:

o ip addr show or ip a: Display IP address informa on.

o ip -c address: Display color-coded IP addresses.

o ip link show: Show all network links.


o ip link set enp3s0 up: Enable interface enp3s0.

o ip link set enp3s0 down: Disable interface enp3s0.

o ip -s link: Display sta s cs for all links.

2. Se ng IP Addresses:

o sudo ip addr add 192.168.1.100/24 dev enp3s0: Add IP address 192.168.1.100/24 to enp3s0.

o sudo ip addr del 192.168.1.100/24 dev enp3s0: Remove IP address from enp3s0.

3. IP Routes:

o ip route show or ip r: Display rou ng table.

o ip route add 10.10.20.0/24 via 192.168.50.100 dev eth0: Add a sta c route.

o ip route add default via 192.168.1.254: Set default gateway.

o ip route del 10.10.20.0/24: Delete a route.

o ip monitor: Monitor IP address, route, and link changes.

4. IPv6 Commands:

o ping6 -c 2 2001:db8:1::20: Ping an IPv6 address.

o route -6 add 2001:db8:1::/64 gw 2001:db8::3: Add IPv6 route.

o route -6 del 2001:db8:1::/64 gw 2001:db8::3: Delete IPv6 route.

o ip route add 2001:db8:1::/64 via 2001:db8::3: Add IPv6 route using ip.

o ip route del 2001:db8:1::/64 via 2001:db8::3: Remove IPv6 route using ip.

Network Troubleshoo ng Tools

1. Ping and Traceroute:

o ping [host/IP]: Ping an IPv4 address.

o ping6 [host/IP]: Ping an IPv6 address.

o traceroute [host/IP]: Trace the route to a remote host.

o tracepath [host/IP]: Trace route and MTU to a remote host.

2. DNS Lookup:

o host [domain/IP]: Basic DNS lookup.

o host -t NS lpi.org: Lookup specific DNS records (e.g., NS, SOA).

o dig [domain]: Detailed DNS informa on.

o getent hosts dns1.lpi.org: Retrieve host informa on from /etc/hosts or DNS.


3. Route and Netstat Commands:

o route -n: Display the rou ng table.

o netstat -rn: Show rou ng table with netstat.

4. Addi onal Commands:

o lspci | fgrep Ethernet: Check if Ethernet card is detected.

o resolvectl status: Check DNS server being used.

o journalctl -u systemd-resolved -f: View DNS resolu on logs.

20 FTP (Data)
21 FTP (Control)
22 SSH
23 Telnet
25 SMTP
53 DNS
80 HTTP
443 HTTPS

You might also like