alias loadavg='sysctl vm.loadavg | cut -d" " -f3,4,5'
loadavg any time I want to see how my cpu cores are doing.a brief and biased look at the state of computer technology today.
alias loadavg='sysctl vm.loadavg | cut -d" " -f3,4,5'
loadavg any time I want to see how my cpu cores are doing.alias l='ls -F'
alias la='ls -a'
alias ll='ls -lh'
alias dfh='df -h | grep -v "^[[:alpha:]]"'
alias myps='ps aux | grep ^$(whoami) | sort -k 2b'
alias sched='echo ""; cal; echo ""; calendar -w 3; echo ""'
choco install -y vim doublecmd
choco install vlc
choco install -y powershell4
choco search angry
xargs command. It takes something from standard input and passes it as an argument to another command. For example, if a command expects a user name, you can get that name from somewhere and feed it to the command through xargs:whoami | xargs passwd
passwd can accept a user name through standard input directly, so xargs isn’t needed here. And of course, passwd with no arguments would change the current user’s password anyway. But it is a simple way to illustrate what xargs does. Some commands don’t look for a required argument in the standard input stream, so they won’t read directly from the pipe. xargs takes whatever is in the pipe and sends it as an argument to the command that follows; in this case, passwd.xargs in my .xinitrc file to set a random background wallpaper on my desktop when I start X:find ~/pictures/wallpapers -type f | sort -R | tail -1 | xargs feh --bg-fill
find command locates all the files in my wallpapers directory. The sort command puts the file names in random order and the tail command grabs only the last one in the list. xargs then passes that to feh, an image display utility, which sets the randomly selected file as my wallpaper. And so X greets me with a surprise every time I go GUI.cal and you get the calendar for the current month. To see the calendar for the entire year, run cal 2015.cal 11 2020. Pass cal the month and year of your birth and you’ll see what day of the week was graced by that momentous occasion.cal 9 1752. You might notice something wrong here—September of 1752 is missing eleven days! Is cal broken? Hardly. In September of 1752 the British Empire (finally) adopted the Gregorian calendar to correct an error that was, by that time, eleven days long. What’s cool is that a little UNIX program already knew all that, so you don’t have to worry about accidentally scheduling a Tardis trip for London, September 8, 1752. That is, assuming the Tardis runs a version of UNIX…Get-Help cmdlet provides different levels of verbosity, from printing out basic syntax to highlighting every detail of each argument that a cmdlet will accept. It can even display working examples of how a cmdlet is used, which fits my learning style perfectly. You can also search through the help using the standard shell wildcard characters * and ?. Get-Help about_arithmetic_operators to find out how PowerShell does math, or Get-Help about_if to review how PowerShell makes decisions. If you need to know something about PowerShell, like Prego spaghetti sauce, “It’s in there.”nslookup www.centriq.com
cmd.exe with some fancier command-fu:set host=www.centriq.com
for /f "usebackq tokens=2" %%i in (`nslookup %host%`) do set ipaddr=%%i
nslookup changes its output depending on the information in the DNS record it queries. This command expects the data of interest to be on the last line of output, which will work much of the time, but not always. $host = 'www.centriq.com'
$ipaddr = resolve-dnsname $host | ? ip4address | select -expand ip4address
Resolve-DNSName cmdlet will have an IP address property that we can directly query and save in a variable.foreach ($i in 0..32) {"{0,8} {1,-11}" -f $i, ([System.Math]::Pow(2, $i))}
[System.Net.WebRequest]::Create('http://www.mysite.com/index.html')
$Host.UI.RawUI.CursorPosition = @{x = 20; y = 47}
function Wait-Key {
<#
.SYNOPSIS
Prompts the user to press a key and waits until the user does so.
.DESCRIPTION
The Wait-Key function simulates the DOS program pause. It gives a script an
opportunity to wait for the user to press a key before proceeding.
.PARAMETER Message
The prompt message to display when the script pauses.
#>
[CmdletBinding()] param (
[string] $Message = "Press any key to continue..."
)
$Message
$Host.UI.RawUI.ReadKey("NoEcho, IncludeKeyDown") | Out-Null
} # end function Wait-Key
notepad .\seating_chart.txt
Invoke-Expression ./disk_report.html
ipconfig /displaydns
--% operator between the command and it’s arguments.ICACLS.EXE --% C:\TEST /GRANT USERS:(F)
DIR—or ls for that matter—and get a directory listing. Granted, what I get is not the result of DIR but the PowerShell Get-ChildItem command, so things are a little different, but not completely alien. I can easily create aliases of my own, if I like:Set-Alias -Name unlink -Value Remove-Item
Set-Alias -Name goto -Value Set-Location
when managing a windows server i sometimes find myself needing to copy many files. for the sake of efficiency i head for the command line. the copy command can be used to quickly make a copy of a file:
C:\>copy q1report.txt q2report.txt
this copy command takes two arguments. the first is the file to copy, the second is the name of the new file to create. when you just want to make a copy of a file in a new location, use the destination directory as the second argument:
C:\>copy q1report.txt reports
this will make a copy of q1report.txt in the c:\reports directory. you can copy multiple files at once using wildcards:
C:\>copy q*report.txt reports
when you copy a file only the contents are duplicated. a file's permissions don't copy with it, but the duplicate inherits the permissions of the directory where it gets created. if you want to copy both the file and its access control list, you'll need to use xcopy:
C:\>xcopy /o q1report.txt reports
xcopy can also be used to copy whole directory trees:
C:\>xcopy /s reports d:\
this command will copy the entire directory structure under c:\reports to drive d.
when you need to combine several files into one the copy command can be used for concatenation. just join all the old filenames together with plus symbols and specify the new filename.
C:\>copy q1report.txt+q2report.txt+q3report.txt+q4report.txt annual_report.txt
this works great for combining ascii text files together, but it's not generally very useful with binary files like those created by a word processor.
the copy command can also be used as a quick-and-dirty plain text editor. start with the command copy con filename and then type the lines you want in your file. when you're done, type ctrl-z.
C:\>copy con ls.bat
@echo off
dir
^Z
now your batch file is saved and ready to rock 'n' roll.
for more advanced features, check out the command line help for copy and xcopy, and, as always, be seeing you.