Unix vs PowerShell Commands: A Comparison (Under ...

Unix vs PowerShell Commands: A Comparison (Under Development)

Unix

Powershell/Cmd

Description

/dev/null out-null

bash cat cd chmod

cp

command, cmd, powershell get-content aliases: cat, gc, type set-location aliases: sl, cd, chdir See set-acl attrib set-itemproperty Copy-item

Instead of a pseudo-device, output can be directed to a command: dosomething | out-null. To redirect other streams use: do-something 2>$null create a subshell output a file to stdout

change directory

change file permissions Windows handles file permissions very differently Copy a file or a directory

curl

cut

date df du echo exit

env

invoke-webRequest -uri file alias: curl Select-Object

get-date get-disk

echo exit

get-childitem Env:

retrieve a file using http

Extract columns from output (not quite the same Display a date, extracting fields Show free storage on the disk Show disk utilization output a string, variables Exit a script or a subshell with an error code List the values of environment variables

exec

export file

find finger getfacl grep

head history

start invoke-commmand (see su)

set get-child

get-child-item (use -filter, -recurse)

N/A get-acl NA -match get-content -head n history

Launch a new process. The Powershell version cannot set a file descriptor, it's not a Windows concept set an environment variable file reports on the type of file by looking at its content. get-child only looks at the extension locate a file based on pattern in it's name

Retrieve ACL permissions General REcursive Pattern match A very poor substitute

Retrieve the 1st n lines of a file Retrieve previous commands

hostname $env:hostname

id

$env:username

kill last less

ln -s locate

stop-process Requires a script and admin privileges out-host -paging alias: oh -p new-alias, set-alias get-command

ls

man

mkdir

more

mv

newgrp ping

popd printf

ps pushd pwd

read

rev rm

rmdir

sed setfacl sleep

sort

get-ChildItem aliases: gl, dir get-help alias man New-Item -itemType Directory alias: mkdir out-host -paging alias: oh -p move-item

N/A test-connection ping is a separate command popd "format string" -f valuelist See also: write-host get-process pushd get-location aliases: gl, pwd read-host

N/A Remove-Item aliases: rm, ri, rmdir, rd, del Remove-item alias rmdir N/A set-acl start-sleep see also Thread.sleep(n) sort-object

ssh

ssh (PowerShell 6)

Name of computer Id of User. Not as much info in PowerShell because Windows is different Kill a process by its pid List of logins, either all or by user id Paginate Output

Create a symbolic link to a file Finds available commands Not sure if PowerShell version can find the directory List files in current directory (note options!) Access help

Create a new directory

paginate output

Renames a file and possibly changes its directory

Detect if a remote machine is available

Remove directory from the stack Format output. The details are a bit complex, includes date formats. List info on current process Add a directory to the stack Display current directory

Input a line from the terminal with a prompt Reverses lines in a file Delete a file or files

Delete a directory

Stream editor Set acl file permissions Pause the current process

Powershell sorts by properties Unix sorts using strings, fields and offsets Log in to local or remote computer

su

New-PSSession

stat

get-itemProperty

tail

get-content -tail n

tac

sort-object

tee test, [[ touch

tee-object get-fileProperty new-item

tree tty ulimit umask uname uptime

tree N/A N/A N/A get-cimInstance get-uptime (PowerShell 6+)

*wait, *trap

wait-event see also: new-event

wc

measure-object

which

who, whoami

get-cmd - not sure if this is quite the same. untested. $env:username

Show file properties Retrieve the last n lines from a file 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. Splits a pipeline into multiple streams Test file properties Create a file. PowerShell does not set times Recursively show directory structure Show current terminal Shows user resource limits Set default file permissions System info Shows the uptime of current and domain linked servers In Unix this is based on signals. Events in PowerShell are similar but have more information Counts words, lines and characters in a file Shows which version of a program will be run show users Shows current identity

*Not usually covered in CENG151, CENG200

# of commands covered at present: 65

See also: as a start point

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download