Essential Linux Commands and Quota Management

Classified in Computers

Written at on English with a size of 4.68 KB.

Here's a list of essential Linux commands:

  • lime - Displays the current calendar.
  • lime 1980 - Shows the calendar for the year 1980.
  • cal 12 1980 - Displays the calendar for December 1980.
  • date - Displays the current date.
  • date -s "2009-11-05 18:55" - Changes the system time.
  • who - Shows who is currently logged into the system.
  • who -u - Displays the process ID (PID) of logged-in users.
  • kill -9 3525 - Terminates the process with PID 3525.
  • uname - Outputs the machine's name.
  • uname -a - Shows detailed information about the machine.
  • uptime - Displays how long the machine has been running.
  • du - Displays disk space usage by folders.
  • du -k - Displays disk space usage in 1024-byte blocks.
  • df - Displays disk usage statistics.
  • ps - Displays a general list of running processes.
  • top - Displays a real-time view of the most resource-intensive processes.
  • free - Shows memory availability and statistics.
  • dmesg - Displays kernel messages.
  • lsmod - Shows loaded kernel modules.
  • lspci - Displays hardware components.
  • man - Accesses the system's manual pages.
  • whatis who - Shows a brief description of the who command.
  • whereis who - Shows the location of the who command.

Vi Editor Tips:

  • To quit and save changes: press Esc, then type :x and press Enter.
  • To quit without saving changes: press Esc, then type :q! and press Enter.

Partitioning and Formatting

  • fdisk -l - Lists existing partitions.
  • mkfs.ext3 "path" - Formats a partition with the ext3 filesystem.
  • fdisk /dev/hda - Opens the fdisk utility to create partitions on /dev/hda.

Partitioning Steps:

  1. Press n for new partition.
  2. Choose the partition type (primary or extended).
  3. Specify the partition size (e.g., +1000M for 1000MB).
  4. Press w to write the changes to disk.

After partitioning:

  • partprobe - Informs the kernel about partition table changes.

Disk Quota Management

First, create users for comparison. It is assumed that you know how to create users.

To configure disk quotas:

  1. Mount to view the Linux File System.
  2. Edit /etc/fstab using nano.
  3. Add the following lines (adjusting the path as needed):
    • LABEL=/home /home ext3 defaults 1 2
    • LABEL=/home /home ext3 defaults,usrquota,grpquota 1 2
  4. Remount the filesystem: mount -o remount /home
  5. Run quotacheck -augmv to create, verify, or repair quota control files. Alternatively, use quotacheck ugmv /home.
  6. Verify that the home file system supports quotas by checking for aquota.user and aquota.group files in the /home directory: cd /home followed by ls -l.
  7. Activate quota support: quotaon -ugv /home
  8. To disable disk quotas: quotaoff -v /home

Now that the /home file system has quota support enabled, you can apply quotas to users and groups.

  • edquota -u user1 - Grant quotas to user1.
  • quota -u user1 - Check the quota settings for user1.
  • quota -s -u user1 - View a report of quota usage for user1.
  • edquota -t - Set the grace period (the time a user is allowed to exceed their quota) at the system level.
  • edquota -u user1 -T - Set the grace period for user1.

To schedule quota warnings, edit /etc/crontab and add a line like:

0 0,12 * * * root /usr/sbin/warnquota

Other useful quota commands:

  • quotacheck: To check the file system and update the quota system explicitly.
  • repquota -a: Show details of shares in a particular file system.
  • quotaon / quotaoff: To enable/disable quota system in a given file system.

Entradas relacionadas: