Unix Vs Powershell Commands: a Comparison (Under Development)

Total Page:16

File Type:pdf, Size:1020Kb

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 .
Recommended publications
  • Autocad Command Aliases
    AutoCAD and Its Applications Advanced Appendix D AutoCAD Command Aliases Command Alias 3DALIGN 3AL 3DFACE 3F 3DMOVE 3M 3DORBIT 3DO, ORBIT, 3DVIEW, ISOMETRICVIEW 3DPOLY 3P 3DPRINT 3DP, 3DPLOT, RAPIDPROTOTYPE 3DROTATE 3R 3DSCALE 3S 3DWALK 3DNAVIGATE, 3DW ACTRECORD ARR ACTSTOP ARS -ACTSTOP -ARS ACTUSERINPUT ARU ACTUSERMESSAGE ARM -ACTUSERMESSAGE -ARM ADCENTER ADC, DC, DCENTER ALIGN AL ALLPLAY APLAY ANALYSISCURVATURE CURVATUREANALYSIS ANALYSISZEBRA ZEBRA APPLOAD AP ARC A AREA AA ARRAY AR -ARRAY -AR ATTDEF ATT -ATTDEF -ATT Copyright Goodheart-Willcox Co., Inc. Appendix D — AutoCAD Command Aliases 1 May not be reproduced or posted to a publicly accessible website. Command Alias ATTEDIT ATE -ATTEDIT -ATE, ATTE ATTIPEDIT ATI BACTION AC BCLOSE BC BCPARAMETER CPARAM BEDIT BE BLOCK B -BLOCK -B BOUNDARY BO -BOUNDARY -BO BPARAMETER PARAM BREAK BR BSAVE BS BVSTATE BVS CAMERA CAM CHAMFER CHA CHANGE -CH CHECKSTANDARDS CHK CIRCLE C COLOR COL, COLOUR COMMANDLINE CLI CONSTRAINTBAR CBAR CONSTRAINTSETTINGS CSETTINGS COPY CO, CP CTABLESTYLE CT CVADD INSERTCONTROLPOINT CVHIDE POINTOFF CVREBUILD REBUILD CVREMOVE REMOVECONTROLPOINT CVSHOW POINTON Copyright Goodheart-Willcox Co., Inc. Appendix D — AutoCAD Command Aliases 2 May not be reproduced or posted to a publicly accessible website. Command Alias CYLINDER CYL DATAEXTRACTION DX DATALINK DL DATALINKUPDATE DLU DBCONNECT DBC, DATABASE, DATASOURCE DDGRIPS GR DELCONSTRAINT DELCON DIMALIGNED DAL, DIMALI DIMANGULAR DAN, DIMANG DIMARC DAR DIMBASELINE DBA, DIMBASE DIMCENTER DCE DIMCONSTRAINT DCON DIMCONTINUE DCO, DIMCONT DIMDIAMETER DDI, DIMDIA DIMDISASSOCIATE DDA DIMEDIT DED, DIMED DIMJOGGED DJO, JOG DIMJOGLINE DJL DIMLINEAR DIMLIN, DLI DIMORDINATE DOR, DIMORD DIMOVERRIDE DOV, DIMOVER DIMRADIUS DIMRAD, DRA DIMREASSOCIATE DRE DIMSTYLE D, DIMSTY, DST DIMTEDIT DIMTED DIST DI, LENGTH DIVIDE DIV DONUT DO DRAWINGRECOVERY DRM DRAWORDER DR Copyright Goodheart-Willcox Co., Inc.
    [Show full text]
  • CS101 Lecture 9
    How do you copy/move/rename/remove files? How do you create a directory ? What is redirection and piping? Readings: See CCSO’s Unix pages and 9-2 cp option file1 file2 First Version cp file1 file2 file3 … dirname Second Version This is one version of the cp command. file2 is created and the contents of file1 are copied into file2. If file2 already exits, it This version copies the files file1, file2, file3,… into the directory will be replaced with a new one. dirname. where option is -i Protects you from overwriting an existing file by asking you for a yes or no before it copies a file with an existing name. -r Can be used to copy directories and all their contents into a new directory 9-3 9-4 cs101 jsmith cs101 jsmith pwd data data mp1 pwd mp1 {FILES: mp1_data.m, mp1.m } {FILES: mp1_data.m, mp1.m } Copy the file named mp1_data.m from the cs101/data Copy the file named mp1_data.m from the cs101/data directory into the pwd. directory into the mp1 directory. > cp ~cs101/data/mp1_data.m . > cp ~cs101/data/mp1_data.m mp1 The (.) dot means “here”, that is, your pwd. 9-5 The (.) dot means “here”, that is, your pwd. 9-6 Example: To create a new directory named “temp” and to copy mv option file1 file2 First Version the contents of an existing directory named mp1 into temp, This is one version of the mv command. file1 is renamed file2. where option is -i Protects you from overwriting an existing file by asking you > cp -r mp1 temp for a yes or no before it copies a file with an existing name.
    [Show full text]
  • Lab Exercise – Ipv4
    Lab Exercise – IPv4 Objective To learn about the details of IP (Internet Protocol). IP is the network layer protocol used throughout the Internet. We will examine IP version 4, since it is ubiquitously deployed, while the IP version 6 is partly deployed. The trace is here: https://kevincurran.org/com320/labs/wireshark/trace-ipv4.pcap The text file is here: https://kevincurran.org/com320/labs/wireshark/trace-ipv4.txt Requirements Wireshark: This lab uses the Wireshark software tool to capture and examine a packet trace. A packet trace is a record of traffic at a location on the network, as if a snapshot was taken of all the bits that passed across a particular wire. The packet trace records a timestamp for each packet, along with the bits that make up the packet, from the lower-layer headers to the higher-layer contents. Wireshark runs on most operating systems, including Windows, Mac and Linux. It provides a graphical UI that shows the sequence of packets and the meaning of the bits when interpreted as protocol headers and data. It col- or-codes packets by their type, and has various ways to filter and analyze packets to let you investigate the behavior of network protocols. Wireshark is widely used to troubleshoot networks. You can down- load it from www.wireshark.org if it is not already installed on your computer. We highly recommend that you watch the short, 5 minute video “Introduction to Wireshark” that is on the site. wget / curl: This lab uses wget (Linux and Windows) and curl (Mac) to fetch web resources.
    [Show full text]
  • K30503041: Creating a Virtual Server with ARP And/Or ICMP Disabled at Creation
    K30503041: Creating a virtual server with ARP and/or ICMP disabled at creation Non-Diagnostic Original Publication Date: Apr 16, 2020 Update Date: Apr 16, 2020 Topic You should consider using this procedure under the following condition: You want to create a new virtual server with the Address Resolution Protocol (ARP) and/or the Internet Control Message Protocol (ICMP) disabled at creation. Description In some network environments, you may want to create virtual servers that have ARP and/or ICMP disabled. When creating a new virtual server (one that does not use an IP address of an existing virtual server), you can enable or disable the virtual server. However, you cannot set the IP address of the virtual server with ARP and/or ICMP to 'disabled' when creating the virtual server. You can only enable or disable ARP or ICMP by modifying the virtual address that is automatically created when you create the virtual server. In this scenario, you create the virtual address with ARP and ICMP enabled at the time of creation. You can work around this scenario by creating the virtual address for the virtual server in advance with ARP and/or ICMP disabled. After creating the virtual address, you can then create the virtual server that references the same IP address of the virtual address as the destination IP address of the virtual server. Prerequisites You must meet the following prerequisite to use this procedure: Administrative access to the BIG-IP Configuration utility or the TMOS Shell (tmsh). Note: You cannot create a virtual address using the Configuration utility.
    [Show full text]
  • Openssh-Ldap-Pubkey Documentation Release 0.3.0
    openssh-ldap-pubkey Documentation Release 0.3.0 Kouhei Maeda May 18, 2020 Contents 1 openssh-ldap-pubkey 3 1.1 Status...................................................3 1.2 Requirements...............................................3 1.3 See also..................................................3 2 How to setup LDAP server for openssh-lpk5 2.1 Precondition...............................................5 2.2 Requirements...............................................5 2.3 Install...................................................5 3 How to setup OpenSSH server9 3.1 Precondition...............................................9 3.2 Requirements...............................................9 3.3 Install with nslcd (recommend).....................................9 3.4 Install without nslcd........................................... 11 4 History 13 4.1 0.3.0 (2020-05-18)............................................ 13 4.2 0.2.0 (2018-09-30)............................................ 13 4.3 0.1.3 (2018-08-18)............................................ 13 4.4 0.1.2 (2017-11-25)............................................ 13 4.5 0.1.1 (2015-10-16)............................................ 14 4.6 0.1.0 (2015-10-16)............................................ 14 5 Contributors 15 6 Indices and tables 17 i ii openssh-ldap-pubkey Documentation, Release 0.3.0 Contents: Contents 1 openssh-ldap-pubkey Documentation, Release 0.3.0 2 Contents CHAPTER 1 openssh-ldap-pubkey 1.1 Status 1.2 Requirements 1.2.1 LDAP server • Add openssh-lpk schema. • Add an objectClass ldapPublicKey to user entry. • Add one or more sshPublicKey attribute to user entry. 1.2.2 OpenSSH server • OpenSSH over 6.2. • Installing this utility. • Setup AuthorozedKeysCommand and AuthorizedKeysCommandUser in sshd_config. 1.3 See also • OpenSSH 6.2 release 3 openssh-ldap-pubkey Documentation, Release 0.3.0 • openssh-lpk 4 Chapter 1. openssh-ldap-pubkey CHAPTER 2 How to setup LDAP server for openssh-lpk 2.1 Precondition This article restricts OpenLDAP with slapd_config on Debian systems only.
    [Show full text]
  • Curl User Survey 2019 Analysis
    curl user survey 2019 analysis “there are so many useful features” summary and analysis by Daniel Stenberg version 1 - June 4, 2019 Table of Contents About curl.............................................................................................................................................3 Survey Background..........................................................................................................................3 Number of responses............................................................................................................................4 Returning respondents?........................................................................................................................5 Users living where?..............................................................................................................................6 What kind of users?..............................................................................................................................7 What protocols......................................................................................................................................8 Multiple platforms..............................................................................................................................10 What platforms...................................................................................................................................11 Which Windows versions...................................................................................................................13
    [Show full text]
  • Shell Variables
    Shell Using the command line Orna Agmon ladypine at vipe.technion.ac.il Haifux Shell – p. 1/55 TOC Various shells Customizing the shell getting help and information Combining simple and useful commands output redirection lists of commands job control environment variables Remote shell textual editors textual clients references Shell – p. 2/55 What is the shell? The shell is the wrapper around the system: a communication means between the user and the system The shell is the manner in which the user can interact with the system through the terminal. The shell is also a script interpreter. The simplest script is a bunch of shell commands. Shell scripts are used in order to boot the system. The user can also write and execute shell scripts. Shell – p. 3/55 Shell - which shell? There are several kinds of shells. For example, bash (Bourne Again Shell), csh, tcsh, zsh, ksh (Korn Shell). The most important shell is bash, since it is available on almost every free Unix system. The Linux system scripts use bash. The default shell for the user is set in the /etc/passwd file. Here is a line out of this file for example: dana:x:500:500:Dana,,,:/home/dana:/bin/bash This line means that user dana uses bash (located on the system at /bin/bash) as her default shell. Shell – p. 4/55 Starting to work in another shell If Dana wishes to temporarily use another shell, she can simply call this shell from the command line: [dana@granada ˜]$ bash dana@granada:˜$ #In bash now dana@granada:˜$ exit [dana@granada ˜]$ bash dana@granada:˜$ #In bash now, going to hit ctrl D dana@granada:˜$ exit [dana@granada ˜]$ #In original shell now Shell – p.
    [Show full text]
  • DPDK-Based Userspace TCP/IP Stack Testing SHU MA EBS – KUAFU ALIBABA CLOUD Agenda
    x DPDK-based userspace TCP/IP stack testing SHU MA EBS – KUAFU ALIBABA CLOUD Agenda 1 Background 2 Current status 3 Our practice 4 Q&A Background Luna • high performance network framework • DPDK • Luna Stack (userspace lightweight TCP/IP stack) Product • ESSD (cloud disk) • hundreds of production clusters • tens of thousands of machines Latency • 1/3 kernel • nearly as fast as RDMA https://www.aliyun.com/product/disk Background Challenges in developing Luna Stack • Bug is time-series-related • hard to reproduce • hard to troubleshoot Test Framework • Large number of corner cases 1. bug reproduction • hard to fix 2. trouble shooting • easy to break other cases 3. regression 4. correctness • Convince upper-layer developers • correctness • robustness Current status Linux kernel, FreeBSD • Internal • Low unit test coverage • External (LTP) • 20+ scripts for TCP/IP Testing approaches • Unit test(white box) • need to know code detail, hard to write • Function test(black box) • hard to create scenarios with strict time-series • packetdrill(grey box) • Google, open source • USENIX ATC 2013 • 3 new TCP features, 10 kernel bugs bug fix for Linux kernel Packetdrill: script 4 statements 0 socket(..., SOCK_STREAM, IPPROTO_TCP) = 3 +0 bind(3, ..., ...) = 0 • packets +0 listen(3, 1) = 0 • tcpdump-like syntax • inbound, outbound +0 < S 0:0(0) win 32792 <mss 1460, nop, wscale 7, nop, nop, TS val 0 ecr 0> • system calls +0 > S. 0:0(0) ack 1 <mss 1460, nop, nop, TS val 0 ecr 0, nop, wscale 7> • strace-like syntax +0 `netstat -anp | grep 8080 | grep SYN_RCVD` // examine TCP state • shell commands +.1 < .
    [Show full text]
  • Linux Cheat Sheet
    1 of 4 ########################################### # 1.1. File Commands. # Name: Bash CheatSheet # # # # A little overlook of the Bash basics # ls # lists your files # # ls -l # lists your files in 'long format' # Usage: A Helpful Guide # ls -a # lists all files, including hidden files # # ln -s <filename> <link> # creates symbolic link to file # Author: J. Le Coupanec # touch <filename> # creates or updates your file # Date: 2014/11/04 # cat > <filename> # places standard input into file # Edited: 2015/8/18 – Michael Stobb # more <filename> # shows the first part of a file (q to quit) ########################################### head <filename> # outputs the first 10 lines of file tail <filename> # outputs the last 10 lines of file (-f too) # 0. Shortcuts. emacs <filename> # lets you create and edit a file mv <filename1> <filename2> # moves a file cp <filename1> <filename2> # copies a file CTRL+A # move to beginning of line rm <filename> # removes a file CTRL+B # moves backward one character diff <filename1> <filename2> # compares files, and shows where differ CTRL+C # halts the current command wc <filename> # tells you how many lines, words there are CTRL+D # deletes one character backward or logs out of current session chmod -options <filename> # lets you change the permissions on files CTRL+E # moves to end of line gzip <filename> # compresses files CTRL+F # moves forward one character gunzip <filename> # uncompresses files compressed by gzip CTRL+G # aborts the current editing command and ring the terminal bell gzcat <filename> #
    [Show full text]
  • Configuring Your Login Session
    SSCC Pub.# 7-9 Last revised: 5/18/99 Configuring Your Login Session When you log into UNIX, you are running a program called a shell. The shell is the program that provides you with the prompt and that submits to the computer commands that you type on the command line. This shell is highly configurable. It has already been partially configured for you, but it is possible to change the way that the shell runs. Many shells run under UNIX. The shell that SSCC users use by default is called the tcsh, pronounced "Tee-Cee-shell", or more simply, the C shell. The C shell can be configured using three files called .login, .cshrc, and .logout, which reside in your home directory. Also, many other programs can be configured using the C shell's configuration files. Below are sample configuration files for the C shell and explanations of the commands contained within these files. As you find commands that you would like to include in your configuration files, use an editor (such as EMACS or nuTPU) to add the lines to your own configuration files. Since the first character of configuration files is a dot ("."), the files are called "dot files". They are also called "hidden files" because you cannot see them when you type the ls command. They can only be listed when using the -a option with the ls command. Other commands may have their own setup files. These files almost always begin with a dot and often end with the letters "rc", which stands for "run commands".
    [Show full text]
  • Configuration and Administration of Networking for Fedora 23
    Fedora 23 Networking Guide Configuration and Administration of Networking for Fedora 23 Stephen Wadeley Networking Guide Draft Fedora 23 Networking Guide Configuration and Administration of Networking for Fedora 23 Edition 1.0 Author Stephen Wadeley [email protected] Copyright © 2015 Red Hat, Inc. and others. The text of and illustrations in this document are licensed by Red Hat under a Creative Commons Attribution–Share Alike 3.0 Unported license ("CC-BY-SA"). An explanation of CC-BY-SA is available at http://creativecommons.org/licenses/by-sa/3.0/. The original authors of this document, and Red Hat, designate the Fedora Project as the "Attribution Party" for purposes of CC-BY-SA. In accordance with CC-BY-SA, if you distribute this document or an adaptation of it, you must provide the URL for the original version. Red Hat, as the licensor of this document, waives the right to enforce, and agrees not to assert, Section 4d of CC-BY-SA to the fullest extent permitted by applicable law. Red Hat, Red Hat Enterprise Linux, the Shadowman logo, JBoss, MetaMatrix, Fedora, the Infinity Logo, and RHCE are trademarks of Red Hat, Inc., registered in the United States and other countries. For guidelines on the permitted uses of the Fedora trademarks, refer to https://fedoraproject.org/wiki/ Legal:Trademark_guidelines. Linux® is the registered trademark of Linus Torvalds in the United States and other countries. Java® is a registered trademark of Oracle and/or its affiliates. XFS® is a trademark of Silicon Graphics International Corp. or its subsidiaries in the United States and/or other countries.
    [Show full text]
  • System Analysis and Tuning Guide System Analysis and Tuning Guide SUSE Linux Enterprise Server 15 SP1
    SUSE Linux Enterprise Server 15 SP1 System Analysis and Tuning Guide System Analysis and Tuning Guide SUSE Linux Enterprise Server 15 SP1 An administrator's guide for problem detection, resolution and optimization. Find how to inspect and optimize your system by means of monitoring tools and how to eciently manage resources. Also contains an overview of common problems and solutions and of additional help and documentation resources. Publication Date: September 24, 2021 SUSE LLC 1800 South Novell Place Provo, UT 84606 USA https://documentation.suse.com Copyright © 2006– 2021 SUSE LLC and contributors. All rights reserved. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or (at your option) version 1.3; with the Invariant Section being this copyright notice and license. A copy of the license version 1.2 is included in the section entitled “GNU Free Documentation License”. For SUSE trademarks, see https://www.suse.com/company/legal/ . All other third-party trademarks are the property of their respective owners. Trademark symbols (®, ™ etc.) denote trademarks of SUSE and its aliates. Asterisks (*) denote third-party trademarks. All information found in this book has been compiled with utmost attention to detail. However, this does not guarantee complete accuracy. Neither SUSE LLC, its aliates, the authors nor the translators shall be held liable for possible errors or the consequences thereof. Contents About This Guide xii 1 Available Documentation xiii
    [Show full text]