Linux: Command Line Interface! October 2018 Presenting

Total Page:16

File Type:pdf, Size:1020Kb

Linux: Command Line Interface! October 2018 Presenting Computing in Engineering Education presents Bytes && Bites on Linux: Command Line Interface! October 2018 Presenting Keshavamurthy Judit Flo Gaya: Indireshkumar : Systems Administrator Computational Scientist Why are you here? ● Never heard of linux, I love MacOS or Windows! ● Have heard but never used ● Have some idea and want to know a bit more ● Convince me! ● I already used it and want to know more! ● Free food! Why Linux? Where is it used? ● Open Source ● SuperComputers/Clusters ● Backbone of the internet ● Present everywhere! ● Cloud Platforms ● Research Why Linux? Where is it used? ● It is open source (free!) and highly efficient and reliable. ○ If you aren’t happy with some feature, you can change it! ○ You have full control on your computer/device with minimal space ● The top 500 supercomputers in the world are running Linux as of one year ago (https://www.top500.org/statistics/sublist/) ● Linux servers form the backbone of internet (https://en.wikipedia.org/wiki/Usage_share_of_operating_systems#Market_share_by_category) ● It is present everywhere: smartTVs, powering your Android, Kindles, 3D printers ● Cloud platforms (AWS, Google cloud, even Azure) are mostly based on linux for building linux servers, which are much cheaper than their windows counterparts (bonus, azure’s network is linux managed https://www.wired.com/2015/09/microsoft-using-linux-run-cloud/) ● Linux - essential for data science, machine learning, and deep learning. ● Cool home projects (including Internet of Things) with open software; great OS for startups etc. https://www.youtube.com/watch?v=a7RXsBQjGNM ● MacOS is based on unix (see also: https://www.lifewire.com/mac-os-x-is-not-linux-distribution-2204744) What is Linux? ● An open-source operating system ○ Very similar to Unix, which is not open source (soap opera material). We use GNU Linux/Unix interchangeably ● An operating system (OS) is the software used for all interactions with the computer’s hardware. Other examples - Windows and Mac OS X(which itself is mostly unix-like). ● Unix (Linux) “philosophy” is to design simple and highly specialized programs that have been perfected through years so that they can be used together to build a more complicated software. ● It’s the do-it-yourself philosophy to the max One Linux? ● https://en.wikipedia.org/wiki/List_of_Linux_distributions ● The main distros: ○ Debian ■ Ubuntu ■ LinuxMint ○ RedHat: ■ Fedora ■ CentOS ○ Slackware: ■ Suse The shell ● Part of OS user interacts with. Shell passes the user commands to the kernel (core of OS) ● Multiple shells: bash and tcsh are the most popular. Others: csh, mosh, etc. We use bash in this tutorial. ● There are many ways to accomplish the same task, you can pick and choose which one you like the most. Linux Command Line Interface (CLI) We will use an ssh tool to connect to a linux server. ● If you have a Mac, you can use the terminal on the Mac and the native ssh capability. There are small differences even within bash (shell) between the MacOS implementation (based on UNIX BSD) and the linux (GNU) version of it, but it will not be an issue for this workshop). ● If you have windows, please install MOBAXterm (https://mobaxterm.mobatek.net/) Basic Commands 101 ● Which user am I using?: ● See what’s in the file: >whoami >less test ● What shell are we in?: >cat test >echo $SHELL ● Create a directory ● Where am I? >mkdir dir1 >pwd ● Move files (note file is moved into a directory) ● How can I move from one directory to another: >mv test dir1 >cd <directory_name> >ls -l dir1 ● Change to directory one level up.. ● Copy files >cd .. >cp dir1/test . ● Change back to home directory .. >ls -l >cd >ls -l dir1 ● List files .. ● Removing a directory >ls >mkdir dir2 ● Listing, longer form with more details.. >rmdir dir2 >ls -l >rmdir dir1 ● Create an “empty file”: ● Cannot remove dir1! Try the following: >touch test >rm -r dir1 Basic Commands 101 (Cont) ● Moving a directory (moving is renaming!): Some fun with the terminal: >mkdir dir1 >telnet towel.blinkenlights.nl >mv dir1 dir2 >fortune >mv dir2/dir1 /tmp/dir3 ● What time is it Something useful: >date >pwgen ● What is this file? >factor 169 >file test >curl wttr.in/Boston >file dir1 >for i in {1..9}; do for j in $(seq 1 $i); do echo -ne $i× >file /usr/bin/bash $j=$((i*j))\\t; done; echo;done >file ● Copying multiple files >touch test1 test2 test3 >cp test* dir2 ● What does a command do: >man cat >man less Basic Commands 101 (Cont) ● Man is your friend! Ask for help! ● What are flags/options on commands? ls -l vs ls rm vs rm -r ● Multiple editors: pico, nano, vim, emacs, etc. ● We will concentrate on vim. Some fun references: ○ https://www.openvim.com/ ○ https://vim-adventures.com/ ● vi vs vim ● vim has two modes: normal mode and insert mode ○ When you open a file with vim, you are in the normal mode. → Command mode ○ To change to insert mode: press i (lower case letter i) → Input text ○ Leave the insert mode: press the escape key esc ○ To leave a vim session without saving, go to normal mode and : press :q! Vimtutor ● Vim ships with its own tutorial. If you type “vimtutor” at the cursor, you will be in the tutorial. ○ Work through lesson 1 in vimtutor ○ Once we are done with lesson 1, we will create a simple program (bash script) and run it. ● Now run vimtutor! Bash Scripting ● Open a file and type this: #!/bin/bash #A primitive script to make directories and copy files date rm -rf dir1 dir2 dir3 dir4 touch test1.txt test2.txt test3.txt test4.txt mkdir dir1 dir2 dir3 dir4 #Do you see anything “wrong” below? If you do, correct it! mv test.txt dir1 mv test20.txt dir2 mv test3.txt dir3 mv test4.txt dir4 date echo "All Done!" ● Run the script with: >bash files.sh Intermediate and advanced Linux 1) Useful commands: #!/bin/bash a) grep (egrep), cut b) pipe (|) for i in {1..4} c) redirection (>,>>,<) do d) wildcards touch test$i.txt e) variables (explain $) mkdir dir$i f) du and df mv test$i.txt dir$i g) ulimit done 2) Bash scripting again! a) loops echo All done b) variables c) create a script with a loop to do what files-simple.sh does. Intermediate and advanced Linux (Cont) ● OS specific topics ● Linux distributions (I’d like to do this before so that they can be a bit independent with a) processes (top, ps, ps -ef, kill (signals), their own linux) nohup, nice, etc.) a) centos, ubuntu, suse, etc. b) Memory (free, swap) b) package managers (yum, apt) c) tar, gzip, file, dd c) Installing software: fortune, cowsays, d) export command (bash), setenv (csh, tcsh) sl, bastet e) Cron ● How to remote into your linux (and others) f) users (useradd, passwd, sudo) a) Ssh g) Logs b) Scp ● Network: c) Ssh keys a) Ifconfig, ethtool d) Tunneling ssh b) proc/net ● File systems: xfs, ext3, ext4, fat, fstab c) Nfs, mount ● File structure : /etc, /root, /home d) Ping ● File permissions e) host/dig f) iptables Some URLs Linux tutorials https://people.ischool.berkeley.edu/~kevin/unix-tutorial/toc.html http://www.ee.surrey.ac.uk/Teaching/Unix/ https://ryanstutorials.net/linuxtutorial/ https://www.guru99.com/unix-linux-tutorial.html https://www.tutorialspoint.com/unix/ Bash tutorials https://linuxconfig.org/bash-scripting-tutorial-for-beginners https://ryanstutorials.net/bash-scripting-tutorial/ Online Linux Terminals http://www.webminal.org/ https://linuxcontainers.org/lxd/try-it/ https://itsfoss.com/online-linux-terminals/.
Recommended publications
  • Freenas® 11.0 User Guide
    FreeNAS® 11.0 User Guide June 2017 Edition FreeNAS® IS © 2011-2017 iXsystems FreeNAS® AND THE FreeNAS® LOGO ARE REGISTERED TRADEMARKS OF iXsystems FreeBSD® IS A REGISTERED TRADEMARK OF THE FreeBSD Foundation WRITTEN BY USERS OF THE FreeNAS® network-attached STORAGE OPERATING system. VERSION 11.0 CopYRIGHT © 2011-2017 iXsystems (https://www.ixsystems.com/) CONTENTS WELCOME....................................................1 TYPOGRAPHIC Conventions...........................................2 1 INTRODUCTION 3 1.1 NeW FeaturES IN 11.0..........................................3 1.2 HarDWARE Recommendations.....................................4 1.2.1 RAM...............................................5 1.2.2 The OperATING System DeVICE.................................5 1.2.3 StorAGE Disks AND ContrOLLERS.................................6 1.2.4 Network INTERFACES.......................................7 1.3 Getting Started WITH ZFS........................................8 2 INSTALLING AND UpgrADING 9 2.1 Getting FreeNAS® ............................................9 2.2 PrEPARING THE Media.......................................... 10 2.2.1 On FreeBSD OR Linux...................................... 10 2.2.2 On WindoWS.......................................... 11 2.2.3 On OS X............................................. 11 2.3 Performing THE INSTALLATION....................................... 12 2.4 INSTALLATION TROUBLESHOOTING...................................... 18 2.5 UpgrADING................................................ 19 2.5.1 Caveats:............................................
    [Show full text]
  • Oracle Solaris: the Carrier-Grade Operating System Technical Brief
    An Oracle White Paper February 2011 Oracle Solaris: The Carrier-Grade Operating System Oracle White Paper—Oracle Solaris: The Carrier-Grade OS Executive Summary.............................................................................1 ® Powering Communication—The Oracle Solaris Ecosystem..............3 Integrated and Optimized Stack ......................................................5 End-to-End Security ........................................................................5 Unparalleled Performance and Scalability.......................................6 Increased Reliability ........................................................................7 Unmatched Flexibility ......................................................................7 SCOPE Alliance ..............................................................................7 Security................................................................................................8 Security Hardening and Monitoring .................................................8 Process and User Rights Management...........................................9 Network Security and Encrypted Communications .......................10 Virtualization ......................................................................................13 Oracle VM Server for SPARC .......................................................13 Oracle Solaris Zones .....................................................................14 Virtualized Networking...................................................................15
    [Show full text]
  • MLNX OFED Documentation Rev 5.0-2.1.8.0
    MLNX_OFED Documentation Rev 5.0-2.1.8.0 Exported on May/21/2020 06:13 AM https://docs.mellanox.com/x/JLV-AQ Notice This document is provided for information purposes only and shall not be regarded as a warranty of a certain functionality, condition, or quality of a product. NVIDIA Corporation (“NVIDIA”) makes no representations or warranties, expressed or implied, as to the accuracy or completeness of the information contained in this document and assumes no responsibility for any errors contained herein. NVIDIA shall have no liability for the consequences or use of such information or for any infringement of patents or other rights of third parties that may result from its use. This document is not a commitment to develop, release, or deliver any Material (defined below), code, or functionality. NVIDIA reserves the right to make corrections, modifications, enhancements, improvements, and any other changes to this document, at any time without notice. Customer should obtain the latest relevant information before placing orders and should verify that such information is current and complete. NVIDIA products are sold subject to the NVIDIA standard terms and conditions of sale supplied at the time of order acknowledgement, unless otherwise agreed in an individual sales agreement signed by authorized representatives of NVIDIA and customer (“Terms of Sale”). NVIDIA hereby expressly objects to applying any customer general terms and conditions with regards to the purchase of the NVIDIA product referenced in this document. No contractual obligations are formed either directly or indirectly by this document. NVIDIA products are not designed, authorized, or warranted to be suitable for use in medical, military, aircraft, space, or life support equipment, nor in applications where failure or malfunction of the NVIDIA product can reasonably be expected to result in personal injury, death, or property or environmental damage.
    [Show full text]
  • CST8207 – Linux O/S I
    Mounting a Filesystem Directory Structure Fstab Mount command CST8207 - Algonquin College 2 Chapter 12: page 467 - 496 CST8207 - Algonquin College 3 The mount utility connects filesystems to the Linux directory hierarchy. The mount point is a directory in the local filesystem where you can access mounted filesystem. This directory must exist before you can mount a filesystem. All filesystems visible on the system exist as a mounted filesystem someplace below the root (/) directory CST8207 - Algonquin College 4 can be mounted manually ◦ can be listed in /etc/fstab, but not necessary ◦ all mounting information supplied manually at command line by user or administrator can be mounted automatically on startup ◦ must be listed /etc/fstab, with all appropriate information and options required Every filesystem, drive, storage device is listed as a mounted filesystem associated to a directory someplace under the root (/) directory CST8207 - Algonquin College 5 CST8207 - Algonquin College 6 Benefits Scalable ◦ As new drives are added and new partitions are created, further filesystems can be mounted at various mount points as required. ◦ This means a Linux system does not need to worry about running out of disk space. Transparent ◦ No application would stop working if transferred to a different partition, because access to data is done via the mount point. ◦ Also transparent to user CST8207 - Algonquin College 7 All known filesystems volumes are typically listed in the /etc/fstab (static information about filesystem) file to help automate the mounting process If it is not listed in the /etc/fstab file, then all appropriate information about the filesystem needs to be listed manually at the command line.
    [Show full text]
  • Top 15 ERP Software Vendors – 2010
    Top 15 ERP Software Vendors – 2010 Profiles of the Leading ERP Vendors Find the best ERP system for your company. For more information visit Business-Software.com/ERP. About ERP Software Enterprise resource planning (ERP) is not a new concept. It was introduced more than 40 years ago, when the first ERP system was created to improve inventory control and management at manufacturing firms. Throughout the 70’s and 80’s, as the number of companies deploying ERP increased, its scope expanded quite a bit to include various production and materials management functions, although it was designed primarily for use in manufacturing plants. In the 1990’s, vendors came to realize that other types of business could benefit from ERP, and that in order for a business to achieve true organizational efficiency, it needed to link all its internal business processes in a cohesive and coordinated way. As a result, ERP was transformed into a broad-reaching environment that encompassed all activities across the back office of a company. What is ERP? An ERP system combines methodologies with software and hardware components to integrate numerous critical back-office functions across a company. Made up of a series of “modules”, or applications that are seamlessly linked together through a common database, an ERP system enables various departments or operating units such as Accounting and Finance, Human Resources, Production, and Fulfillment and Distribution to coordinate activities, share information, and collaborate. Key Benefits for Your Company ERP systems are designed to enhance all aspects of key operations across a company’s entire back-office – from planning through execution, management, and control.
    [Show full text]
  • Oracle Database Licensing Information, 11G Release 2 (11.2) E10594-26
    Oracle® Database Licensing Information 11g Release 2 (11.2) E10594-26 July 2012 Oracle Database Licensing Information, 11g Release 2 (11.2) E10594-26 Copyright © 2004, 2012, Oracle and/or its affiliates. All rights reserved. Contributor: Manmeet Ahluwalia, Penny Avril, Charlie Berger, Michelle Bird, Carolyn Bruse, Rich Buchheim, Sandra Cheevers, Leo Cloutier, Bud Endress, Prabhaker Gongloor, Kevin Jernigan, Anil Khilani, Mughees Minhas, Trish McGonigle, Dennis MacNeil, Paul Narth, Anu Natarajan, Paul Needham, Martin Pena, Jill Robinson, Mark Townsend This software and related documentation are provided under a license agreement containing restrictions on use and disclosure and are protected by intellectual property laws. Except as expressly permitted in your license agreement or allowed by law, you may not use, copy, reproduce, translate, broadcast, modify, license, transmit, distribute, exhibit, perform, publish, or display any part, in any form, or by any means. Reverse engineering, disassembly, or decompilation of this software, unless required by law for interoperability, is prohibited. The information contained herein is subject to change without notice and is not warranted to be error-free. If you find any errors, please report them to us in writing. If this is software or related documentation that is delivered to the U.S. Government or anyone licensing it on behalf of the U.S. Government, the following notice is applicable: U.S. GOVERNMENT END USERS: Oracle programs, including any operating system, integrated software, any programs installed on the hardware, and/or documentation, delivered to U.S. Government end users are "commercial computer software" pursuant to the applicable Federal Acquisition Regulation and agency-specific supplemental regulations.
    [Show full text]
  • UKUI: a Lightweight Desktop Environment Based on Pluggable
    2016 International Conference on Artificial Intelligence and Computer Science (AICS 2016) ISBN: 978-1-60595-411-0 UKUI: A Lightweight Desktop Environment Based on Pluggable Framework for Linux Distribution Jie YU1, Lu SI1,*, Jun MA1, Lei LUO1, Xiao-dong LIU1, Ya-ting KUANG2, Huan PENG2, Rui LI1, Jin-zhu KONG2 and Qing-bo WU1 1College of Computer, National University of Defense Technology, Changsha, China 2Tianjin KYLIN Information Technology Co., Ltd, Tianjin, China *[email protected] *Corresponding author Keywords: Desktop environment, Ubuntu, User interface. Abstract. Ubuntu is an operating system with Linux kernel based on Debian and distributed as free and open-source software. It uses Unity as its default desktop environment, which results in more difficulties of usage for Microsoft Windows users. In this paper, we present a lightweight desktop environment named UKUI based on UbuntuKylin, the official Chinese version of Ubuntu, for Linux distribution. It is designed as a pluggable framework and provides better user experience during human-computer interaction. In order to evaluate the performance of UKUI, a set of testing bench suits were performed on a personal computer. Overall, the results showed that UKUI has better performance compared with Unity. Introduction Linux is a freely available operating system (OS) originated by Linux Torvalds and further developed by thousands of others. Typically, Linux is packaged in a form known as a Linux distribution for both desktop and server use. Some of the most popular mainstream Linux distributions are Red Hat [1], Ubuntu [2], Arch [3], openSUSY [4], Gentoo [5], etc. There are several desktop environments available for nowadays modern Linux distributions, such as XFCE [6], GNOME [7], KDE [8] and LXDE [9].
    [Show full text]
  • Modern Programming Languages CS508 Virtual University of Pakistan
    Modern Programming Languages (CS508) VU Modern Programming Languages CS508 Virtual University of Pakistan Leaders in Education Technology 1 © Copyright Virtual University of Pakistan Modern Programming Languages (CS508) VU TABLE of CONTENTS Course Objectives...........................................................................................................................4 Introduction and Historical Background (Lecture 1-8)..............................................................5 Language Evaluation Criterion.....................................................................................................6 Language Evaluation Criterion...................................................................................................15 An Introduction to SNOBOL (Lecture 9-12).............................................................................32 Ada Programming Language: An Introduction (Lecture 13-17).............................................45 LISP Programming Language: An Introduction (Lecture 18-21)...........................................63 PROLOG - Programming in Logic (Lecture 22-26) .................................................................77 Java Programming Language (Lecture 27-30)..........................................................................92 C# Programming Language (Lecture 31-34) ...........................................................................111 PHP – Personal Home Page PHP: Hypertext Preprocessor (Lecture 35-37)........................129 Modern Programming Languages-JavaScript
    [Show full text]
  • Avoiding the Top 10 Software Security Design Flaws
    AVOIDING THE TOP 10 SOFTWARE SECURITY DESIGN FLAWS Iván Arce, Kathleen Clark-Fisher, Neil Daswani, Jim DelGrosso, Danny Dhillon, Christoph Kern, Tadayoshi Kohno, Carl Landwehr, Gary McGraw, Brook Schoenfield, Margo Seltzer, Diomidis Spinellis, Izar Tarandach, and Jacob West CONTENTS Introduction ..................................................................................................................................................... 5 Mission Statement ..........................................................................................................................................6 Preamble ........................................................................................................................................................... 7 Earn or Give, but Never Assume, Trust ...................................................................................................9 Use an Authentication Mechanism that Cannot be Bypassed or Tampered With .................... 11 Authorize after You Authenticate ...........................................................................................................13 Strictly Separate Data and Control Instructions, and Never Process Control Instructions Received from Untrusted Sources ........................................................................................................... 14 Define an Approach that Ensures all Data are Explicitly Validated .............................................16 Use Cryptography Correctly ....................................................................................................................
    [Show full text]
  • Linux Hacking Case Studies Part 4: Sudo Horror Stories
    Linux Hacking Case Studies Part 4: Sudo Horror Stories written by Scott Sutherland | March 26, 2020 This blog will cover different ways to approach SSH password guessing and attacking sudo applications to gain a root shell on a Linux system. This case study commonly makes appearances in CTFs, but the general approach for attacking weak passwords and sudo applications can be applied to many real world environments. This should be a fun walk through for people new to penetration testing. This is the fourth of a five part blog series highlighting entry points and local privilege escalation paths commonly found on Linux systems during network penetration tests. Below are links to the first three blogs in the series: Linux Hacking Case Study Part 1: Rsync Linux Hacking Case Study Part 2: NFS Linux Hacking Case Study Part 3: phpMyAdmin Below is an overview of what will be covered in this blog: Finding SSH Servers Dictionary Attacks against SSH Servers Viewing Sudoers Execution Options Exploiting Sudo sh Exploiting Sudo VI Exploiting Sudo Python Exploiting Sudo Nmap Finding SSH Servers Before we can start password guessing or attacking sudo applications, we need to find some SSH servers to go after. Luckily Nmap and similar port scanning tools make that pretty easy because most vendors still run SSH on the default port of 22. Below is a sample Nmap command and screenshot to get you started. nmap -sS -sV -p22 192.168.1.0/24 -oA sshscan Once you’ve run the port scan you can quickly parse the results to make a file containing a list of SSH servers to target.
    [Show full text]
  • Unix/Linux Command Reference
    Unix/Linux Command Reference .com File Commands System Info ls – directory listing date – show the current date and time ls -al – formatted listing with hidden files cal – show this month's calendar cd dir - change directory to dir uptime – show current uptime cd – change to home w – display who is online pwd – show current directory whoami – who you are logged in as mkdir dir – create a directory dir finger user – display information about user rm file – delete file uname -a – show kernel information rm -r dir – delete directory dir cat /proc/cpuinfo – cpu information rm -f file – force remove file cat /proc/meminfo – memory information rm -rf dir – force remove directory dir * man command – show the manual for command cp file1 file2 – copy file1 to file2 df – show disk usage cp -r dir1 dir2 – copy dir1 to dir2; create dir2 if it du – show directory space usage doesn't exist free – show memory and swap usage mv file1 file2 – rename or move file1 to file2 whereis app – show possible locations of app if file2 is an existing directory, moves file1 into which app – show which app will be run by default directory file2 ln -s file link – create symbolic link link to file Compression touch file – create or update file tar cf file.tar files – create a tar named cat > file – places standard input into file file.tar containing files more file – output the contents of file tar xf file.tar – extract the files from file.tar head file – output the first 10 lines of file tar czf file.tar.gz files – create a tar with tail file – output the last 10 lines
    [Show full text]
  • 101 Useful Linux Commands - Haydenjames.Io
    101 Useful Linux Commands - haydenjames.io Some of these commands require elevated permissions (sudo) to run. Enjoy! 1. Execute the previous command used: !! 2. Execute a previous command starting with a specific letter. Example: !s 3. Short way to copy or backup a file before you edit it. For example, copy nginx.conf cp nginx.conf{,.bak} 4. Toggle between current directory and last directory cd - 5. Move to parent (higher level) directory. Note the space! cd .. 6. Go to home directory cd ~ 7. Go to home directory cd $HOME 8. Go to home directory (when used alone) cd 9. Set permissions to 755. Corresponds to these permissions: (-rwx-r-x-r-x), arranged in this sequence: (owner-group-other) chmod 755 <filename> 10. Add execute permission to all users. chmod a+x <filename> 11. Changes ownership of a file or directory to . chown <username> 12. Make a backup copy of a file (named file.backup) cp <file> <file>.backup 13. Copy file1, use it to create file2 cp <file1> <file2> 14. Copy directory1 and all its contents (recursively) into directory2 cp -r <directory1> <directory2>/ 15. Display date date 16. Zero the sdb drive. You may want to use GParted to format the drive afterward. You need elevated permissions to run this (sudo). dd if=/dev/zero of=/dev/sdb 17. Display disk space usage df -h 18. Take detailed messages from OS and input to text file dmesg>dmesg.txt 19. Display a LOT of system information. I usually pipe output to less. You need elevated permissions to run this (sudo).
    [Show full text]