Skip to content

Latest commit

 

History

History
102 lines (78 loc) · 2.97 KB

Cheat_sheet_bash_Linux.md

File metadata and controls

102 lines (78 loc) · 2.97 KB

Bash Script (Linux commands)

Here you will see a summary of the common commands use in Linux (Unix) environment. We will just give examples of the ones we will use more frequently during the workshop. This commands can't be used in Windows environment unless you use a Linux emulator. If you need information in the terminal about an specific Linux/Unix command you can type a command line on the terminal:

$ man ls

To escape from the manual, just type: q

File Commands

File commands

Examples - working with directories:

$ ls
$ ls -al
$ ls -alrt
$ pwd
$ mkdir codes
$ mkdir temp temp1
$ mkdir -p temp2/ok
$ cat file.txt
$ cat file.txt file2.txt > fileOut.txt
$ rm file.txt
$ rm -r temp2/ok
$ rm -r temp2
$ df -h

Note: rm * it is a dangerous command that should be use with care, you might lose all your work!!

Examples - Create a File:**

Method 1: Using nano editor:

$ nano file.txt

Then you will get the screen editor where you can type in e.g. type echo "Hello World!".

To save your changes and exit the editor type: ctrl + x and choose Yes to save your changes. Method 2: Using cat command.

$ cat >file2.txt
"Hello Universe!"

To exit press: ctrl + d".

Directory

Directory Access

Disk usage

Disk_usage

File transfer and Remote Access

Remote_access

Search

Search

System

System

Process Related

Process_related

Virtual terminal (Screen)

Screen command Description
screen -S name_of_terminal Assigning name to the virtual terminal or screen session.
screen -ls List all the virtual sessions or screens opened.
screen -X -S name_of_terminal quit Kill an specific virtual terminal.
screen -r name_of_terminal Attach to the virtual terminal or screen.
Press “Ctrl-A” and “d“ Detach from virtual terminal or screen.
Press "Ctrl-A” and “K” This command will leave and kill the virtual terminal or screen
Press “Ctrl-A” and “n“ Switching to the next virtual terminal or screen.
Press “Ctrl-A” and “p“ Switching to the previous virtual terminal or screen

Reference