AN INTRO TO UNIX/LINUX COMMANDS BY: JIAYANG WANG.
-
Upload
prudence-waters -
Category
Documents
-
view
226 -
download
3
Transcript of AN INTRO TO UNIX/LINUX COMMANDS BY: JIAYANG WANG.
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
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
HOW TO GET TO THE TERMINAL IN KALI
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.
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
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
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/
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
HOW TO TOUCH
• Touch: creates a empty file
• %touch me.txt
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
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
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
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
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
HOW TO DELETE A FILE
• %rm filename: deletes the file
HOW TO DELETE A DIRECTORY
• %rmdir directoryname: removes the directory
• %rm -rf directoryname: removes the directory and its contents
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