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

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    3 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us