Showing posts with label Command Line. Show all posts
Showing posts with label Command Line. Show all posts

Tuesday, 20 February 2024

Optimizing Disk Space: A Visual Guide to Linux's du Command

Understanding how to monitor and manage disk usage is essential for both administrators and power users. One powerful command that stands out for its utility in managing disk space is 

du -hsx /* | sort -rh | head -10

Let's break down this command to understand its functionality and significance.

The command du -hsx /* | sort -rh | head -10 is a pipeline of three commands, each performing a unique function, working together to report the sizes of the top 10 directories that occupy the most space on the root filesystem:

du -hsx /*: The du (disk usage) command estimates file space usage. The flags used here are:

-h (human-readable): Converts the output to a more readable format using the most appropriate unit (KB, MB, GB).

-s (summarize): Displays only a total for each argument.

-x (one file system): Skips directories on different filesystems, focusing only on the root filesystem.

This part of the command scans all directories in the root (/*) and provides a summarized, human-readable output of their sizes, ensuring it only accounts for directories on the root filesystem.

sort -rh: This command sorts the output from the du command.

-r (reverse): Sorts the output in reverse order, placing larger items at the top.

-h (human-readable): Sorts numbers with unit suffixes (K, M, G, etc.), ensuring that 10M is considered larger than 9G.

head -10: This final command in the pipeline takes the sorted list of directory sizes and displays the top 10 entries. This is particularly useful for quickly identifying which directories are using the most disk space, allowing for efficient space management decisions.

This command is especially useful for system administrators and users who need to quickly identify high disk usage directories to clean up or monitor space usage. By focusing on the largest directories, one can efficiently manage disk space, ensuring that the system remains stable and that critical operations have enough space to function correctly.

Thursday, 8 September 2022

Removing Drivers from Windows Driver store (Enabling Core Isolation)

 Sometimes when you are enabling core isolation you may get an error which says drivers are blocking you it form being enabled.

You should then get an option to see which drivers are doing it.  the first check is to see if its an linked to a device you use or just something that could of been installed a while back.

second step would be to check for driver updates for the device and run the scan again.  but if you tried all that and its still not working you can force remove the drivers if they are not linked to a active device.

Open command prompt as administrator.

For a list of drivers you can run
pnputil /enum-drivers

But if you know the inf file you need to remove you can just run the below
pnputil /delete-driver <INF NAME>.inf

The core isolation should give you the inf name as part of the error.

Tuesday, 9 August 2022

Cisco - Basic Make / change Object network

enable
configure terminal
object network <NAME>

Then one of the following 

host ip_address

range ip_address_1 ip_address_2

subnet subnet_address

Monday, 12 April 2021

Port Exhaustion and DNS server on Windows 2012 / 2008

Seen an old issue on some servers where the DNS server starts to trigger port exhaustion on a server, this can lead to the server starting to act really weird, applications will start the time out, window shares will stop working but some may remain if the connection was made before it happened.

The problem is that once you have it you can not check as the server is half locked up and may not running any applications so you have to reboot which in turn removes the issue.

but if its DNS getting out of control you can see this by running the following as administrator in cmd

netstate -aon

Which will show you all the ports that the system has open,  if you notice a process id taking an usually amount of ports, say like the DNS Server process taking a lot even when restarted you can limit this with the follow reg key.

  • Open regedit.exe and expand the HKLM hive
  • Navigate to SYSTEM\CurrentControlSet\services\DNS\Parameters
  • Create a new DWORD value named SocketPoolSize
  • Set a decimal value between 0 and 10000
  • Restart the DNS Server service: net stop dns && net start dns
I would recommend starting at 500 and see the network response and if you get any DNS issue increase until you get a nice balance.

I would also recommend DNS servers to be they own OS and not mixed with everything else like a resurrected SBS system as they where the primary sources of port exhaustion.

Monday, 7 December 2020

Quick command line for making a local admin account

 Sometimes with remote tools you have remote screen access with software such as TeamViewer or ISL Light.

and at times you also have a remote command line interface too but no local admin account to get in to a desktop.

open the command line CMD or remote command line tool and type

net user admin-tmp <Password> /add
net localgroup administrators admin-tmp /add

If you need to view a list of local users type

net user

and to check a local accounts password

net user <Name> <Password>

To delete accounts

 net user <Name> /delete