Quick viewing(Text Mode)

Unix Vs Powershell Commands: a Comparison (Under Development)

Unix Vs Powershell Commands: a Comparison (Under Development)

Unix vs PowerShell Commands: A Comparison (Under Development)

Unix Powershell/Cmd Description

/dev/null out-null Instead of a pseudo-device, output can be directed to a : do- something | out-null. To redirect other streams use: do-something 2>$null command, cmd, create a subshell get-content output a to stdout aliases: cat, gc, set-location change aliases: sl, cd, chdir See set-acl change file permissions Windows handles file permissions very set-itemproperty differently -item Copy a file or a directory invoke-webRequest -uri file retrieve a file using http alias: curl Select-Object Extract columns from output (not quite the same date get-date Display a date, extracting fields get-disk Show free storage on the disk Show disk utilization echo output a string, variables exit Exit a script or a subshell with an error code get-childitem Env: List the values of environment variables exec Launch a new process. The Powershell invoke-commmand (see ) version cannot set a file descriptor, it’s not a Windows concept export set set an file get-child file reports on the type of file by looking its content. get-child only looks at the extension get-child-item (use -filter, -recurse) a file based on pattern in it’s name finger N/A getfacl get-acl Retrieve ACL permissions NA General REcursive Pattern match ://devblogs.microsoft.com/scripting/use- A very poor substitute powershell-to-toggle-the-archive-bit-on- files/select-string -match get-content -head n Retrieve the 1st n lines of a file history Retrieve previous commands hostname $env:hostname Name of computer id $env:username Id of User. Not as much in PowerShell because Windows is different stop-process Kill a process by its pid last Requires a script and admin privileges List of logins, either all or by user id out- -paging Paginate Output alias: oh -p -s new-alias, set-alias Create a symbolic to a file locate get-command Finds available commands Not sure if PowerShell version can find the directory get-ChildItem List files in current directory (note aliases: gl, options!) man get- Access help alias man New-Item -itemType Directory Create a new directory alias: mkdir out-host -paging paginate output alias: oh -p -item Renames a file and possibly changes its directory newgrp N/A ping -connection Detect if a remote machine is available ping is a separate command popd popd Remove directory from the stack string” -f valuelist Format output. The details are a bit See also: -host complex, includes date formats. get-process List info on current process pushd pushd Add a directory to the stack get-location Display current directory aliases: gl, pwd read read-host Input a line from the terminal with a prompt rev N/A Reverses lines in a file Remove-Item Delete a file or files aliases: rm, ri, , rd, rmdir Remove-item Delete a directory alias rmdir N/A Stream editor setfacl set-acl Set acl file permissions start-sleep Pause the current process see also Thread.sleep(n) sort-object Powershell sorts by properties Unix sorts using , fields and offsets ssh ssh (PowerShell 6) Log in to local or remote computer su New-PSSession stat get-itemProperty Show file properties get-content -tail n Retrieve the last n lines from a file tac sort-object Reverse the order of a command’s output Not quite the same in Powershell. One can write a script to add line #s to the output and reverse sort. tee-object Splits a pipeline into multiple streams test, [[ get-fileProperty Test file properties new-item Create a file. PowerShell does not set times tree Recursively show directory structure tty N/A Show current terminal ulimit N/A Shows user resource limits N/A Set default file permissions get-cimInstance System info get-uptime (PowerShell 6+) Shows the uptime of current and domain linked servers *, wait-event In Unix this is based on signals. Events *trap see also: new-event in PowerShell are similar but have more information measure-object Counts words, lines and characters in a file get-cmd - not sure if this is quite the same. Shows which version of a program will untested. be run , $env:username show users Shows current identity

*Not usually covered in CENG151, CENG200

# of commands covered at present: 65

See also: https://docs.microsoft.com/en-us/powershell/scripting/learn/understanding-important- powershell-concepts?view=powershell-7 as a start point