18
AN INTRO TO UNIX/LINUX COMMANDS BY: JIAYANG WANG

AN INTRO TO UNIX/LINUX COMMANDS BY: JIAYANG WANG

Embed Size (px)

Citation preview

Page 1: AN INTRO TO UNIX/LINUX COMMANDS BY: JIAYANG WANG

AN INTRO TO UNIX/LINUX COMMANDS

BY: JIAYANG WANG

Page 2: AN INTRO TO UNIX/LINUX COMMANDS BY: JIAYANG WANG

WHAT IS UNIX?

• Operating system developed in the 1960s

• Still being developed

• Usually Command line based

• Multiuser and multitasking

• You can read more about UNIX here: http://www.ee.surrey.ac.uk/Teaching/Unix/unixintro.html

Page 3: AN INTRO TO UNIX/LINUX COMMANDS BY: JIAYANG WANG

USEFUL SOFTWARE FOR CONNECTING TO REMOTE MACHINE

• PuTTY: Free SSH Client – Allows you to remotely connect to another machine in a secure way

• Filezilla: Free FTP Software – Allows you to transfer files to and from another machine

Page 4: AN INTRO TO UNIX/LINUX COMMANDS BY: JIAYANG WANG

HOW TO GET TO THE TERMINAL IN KALI

Page 5: AN INTRO TO UNIX/LINUX COMMANDS BY: JIAYANG WANG

HOW TO NAVIGATE

• ls (list) – this command shows all the files and subdirectories of your current directory.

• ls –hal : better version (human readable, all, long listing format).

• cd (Change Directory): this command changes your directory to the specified one.

• Example %cd desktop will take you to the desktop directory

• Example %cd .. Will take you to the parent directory

• pwd (print working directory): shows you where you are in relation to the whole file system.

Page 6: AN INTRO TO UNIX/LINUX COMMANDS BY: JIAYANG WANG

HOW TO CREATE NEW DIRECTORY(FOLDER)

• mkdir (make directory): Allows you to create a directory(folder) in your current directory

• Similar to right clicking and choosing new folder in windows

• Example: mkdir newdirectory

Page 7: AN INTRO TO UNIX/LINUX COMMANDS BY: JIAYANG WANG

HOW TO VIEW CONTENTS OF A FILE

• cat (concatenate): displays contents of the file to the screen

• Example: %cat randomfile.txt

• less: displays contents of the file to the screen a page at a time

• Example: %less randomfile.txt

• [space-bar] to visit next page, [q] to quit

Page 8: AN INTRO TO UNIX/LINUX COMMANDS BY: JIAYANG WANG

HOW TO SEARCH A FILE FOR KEYWORDS

• Grep: searches files for specific words or patterns

• Example of searching for the word password in passwords.txt: %grep password password.txt

• Example of searching for a phrase in password.txt: %grep ‘my password’ password.txt

• Example of search for a phrase in a directory: grep -R 'string' dir/

Page 9: AN INTRO TO UNIX/LINUX COMMANDS BY: JIAYANG WANG

UNIX TEXT EDITORS

• Nano: very simple to use editor, we will be using nano in our tutorial

• Vim: a bit more complex to use but it is very powerful and very rewarding when mastered

Page 10: AN INTRO TO UNIX/LINUX COMMANDS BY: JIAYANG WANG

HOW TO TOUCH

• Touch: creates a empty file

• %touch me.txt

Page 11: AN INTRO TO UNIX/LINUX COMMANDS BY: JIAYANG WANG

CREATE A FILE USING NANO

• %nano filename

• Example c file: %nano sample.c

• Example c++ file: %nano sample.cpp

• Example java file: %nano sample.java

Page 12: AN INTRO TO UNIX/LINUX COMMANDS BY: JIAYANG WANG

SAVING A FILE IN NANO

• Press ctrl-o to save the file

• Press ctrl-x to exit

• nano will ask you if you want to save, press y to save press n to not save

• It will prompt you to enter a file name

• After editing the file name, you can press enter

Page 13: AN INTRO TO UNIX/LINUX COMMANDS BY: JIAYANG WANG

HOW TO COMPILE A C FILE IN UNIX

• gcc filename.c

• This will create an executable called a.out

• You can run the executable by running ./a.out

• gcc filename.c –o executablename

• This will create an executable with whatever name you specify

• You can run the executable by running ./executablename

Page 14: AN INTRO TO UNIX/LINUX COMMANDS BY: JIAYANG WANG

HOW TO COMPILE A C++ FILE IN UNIX

• Very similar to c

• g++ filename.cpp

• This will create an executable called a.out

• You can run the executable by running ./a.out

• g++ filename.cpp –o executablename

• This will create an executable with whatever name you specify

• You can run the executable by running ./executablename

Page 15: AN INTRO TO UNIX/LINUX COMMANDS BY: JIAYANG WANG

HOW TO COMPILE A JAVA PROGRAM IN UNIX

• javac filename.java

• This will create a .class file called filename.class

• java filename

• This will run the application

Page 16: AN INTRO TO UNIX/LINUX COMMANDS BY: JIAYANG WANG

HOW TO DELETE A FILE

• %rm filename: deletes the file

Page 17: AN INTRO TO UNIX/LINUX COMMANDS BY: JIAYANG WANG

HOW TO DELETE A DIRECTORY

• %rmdir directoryname: removes the directory

• %rm -rf directoryname: removes the directory and its contents

Page 18: AN INTRO TO UNIX/LINUX COMMANDS BY: JIAYANG WANG

WANT TO LEARN MORE? HERES SOME GREAT RESOURCES

• UNIX Tutorial for Beginners: http://www.ee.surrey.ac.uk/Teaching/Unix/

• Learn UNIX the hard way: https://nixsrv.com/llthw