Journal: Software Development

Email: mail@appsoftware.com

Software development notes and articles

A journal for sharing all things software development related


Common Commands

Wed, 12 Jun 2019 11:19 UTC

A collection of common commands on Linux / Bash systems

Bash

Execute script

Use chmod 700 scriptname first.

./scriptname

Check permissions on files in current directory

ls -lh

Go to last directory

$ cd -

Get disk usage (space)

https://askubuntu.com/questions/400807/is-there-an-easy-command-line-command-to-check-disk-space

$ df -h

Reboot machine

 $ sudo reboot

Change owner of file

$ chown

Change file permissions

chmod

Copy

C-S-c

Paste

C-S-v

Navigating directories faster

https://mhoffman.github.io/2015/05/21/how-to-navigate-directories-with-the-shell.html

New tab (keyboard shortcut)

C-S-t

Search through history

C-r / C-s

http://www.gnu.org/software/bash/manual/html_node/Searching.html

Remove Directories

Force removal recusively

$ sudo rm -rf somefolder

SCP - transfer file to remove server

Copy automation file using scp:

https://unix.stackexchange.com/questions/232946/how-to-copy-all-files-from-a-directory-to-a-remote-directory-using-scp https://stackoverflow.com/questions/11388014/using-scp-to-copy-a-file-to-amazon-ec2-instance

$ scp -i "~/.ssh/app-software-application-server-key-pair.pem" -r ~/src/app-software-automation ubuntu@ec2-3-8-74-189.eu-west-2.compute.amazonaws.com:~/.

Get man (manual) pages

$ man <command>

Concatenate files and print on the standard output

$ cat file1, file2 

Find in file names

(Searching for files starting with BIOS)

find -name "BIOS*"

Grep find with file name and line numbers

(Searching for word BIOS in text files)

$ grep -H -n --with-filename "BIOS" *.txt

Exit SSH / docker exec etc.

$ exit

Vi

Move to "command mode" - I have no idea if that's what it's called. Where can call :wq etc

Esc

Insert

Insert

Replace

Insert

Write and quit:

:wq

To open a file:

vi \<file match text \>

Cygwin

Accessing files on Windows C:/

$cd /cygdrive/c

Get path to Cygwin folder on Windows

$cygpath -w ~

https://stackoverflow.com/questions/18909767/cygwin-cant-find-my-files

List running daemons

https://unix.stackexchange.com/questions/175380/how-to-list-all-running-daemons

Various ways of doing this

Cheat sheet:

2lyhw9h3gs331.jpg

Source: https://www.reddit.com/r/linuxmasterrace/comments/bzhtw2/basic_linux_commands/

The information on this site is provided “AS IS” and without warranties of any kind either express or implied. To the fullest extent permissible pursuant to applicable laws, the author disclaims all warranties, express or implied, including, but not limited to, implied warranties of merchantability, non-infringement and suitability for a particular purpose.

Linux Bash & Cygwin