CLI more - 1

$ clear

$ who am i
$ whoami

count files

$ ls -l | wc -l
$ ls -l *.md | wc -l
$ ls -F | grep -V / | wc -l

shutdown / reboot

$ sudo reboot
$ sudo shutdown -h now

size

// size of target_dir
$ du -sh target_dir

// size of disk
$ df -h

move or copy

$mv old_dir_path new_dir_path

$cp -r source_dir target_dir

scp

// remote foo.txt to local
$ scp username@remote.edu:/home/username/foo.txt .

// local foo.txt to remote
$ scp foo.txt username@remote.edu:/home/username/dirname

find

find . -type f -name 'file_name'

Shebang

script.sh

#!/bin/bash
echo "Script is fun!!"
$ chmod 755 script.sh
$ ./script.sh &

#! interpreter

& return pid

#!/usr/bin/python
a = 1
b = 2
print('a + b = ', a + b)

Variable

VARIABLE_NAME="value"
SERVER_NAME=$(command)

echo "The output contains ${SERVER_NAME}"

variable name should be uppercase

old syntax: `SERVER_NAME=hostname```

Last updated

Was this helpful?