Terminal operations and command line
- Open the terminal: Use the shortcut key
Ctrl + Alt + T
to open the terminal. - Common command line operations:
- Switch directories: use
cd
the command, for examplecd /path/to/directory
. - View file contents: Use
cat
the command, for examplecat filename.txt
. - Create a file: use
touch
the command, for exampletouch filename.txt
. - Delete files: Use
rm
the command, for examplerm filename.txt
.
- Switch directories: use
- File and directory management:
- List directory contents: Use
ls
commands such asls
orls /path/to/directory
. - Switch directories: use
cd
the command, for examplecd /path/to/directory
. - To view the current directory path: use
pwd
the command, for examplepwd
. - Create a directory: Use
mkdir
the command, for examplemkdir directoryname
. - Delete a directory: use
rmdir
the command, for examplermdir directoryname
.
- List directory contents: Use
- Package management:
- Install a package: Use
apt-get
the command, for examplesudo apt-get install packagename
. - Update packages: Use
apt-get
the command, for examplesudo apt-get update
. - Uninstall a package: use
apt-get
the command, for examplesudo apt-get remove packagename
.
- Install a package: Use
- System information and monitoring:
- View system information: Use
uname
the command, for exampleuname -a
. - View system resource usage: Use
top
the command, for exampletop
. - View memory usage: Use
free
the command, for examplefree -h
. - View disk usage: Use
df
the command, for exampledf -h
.
- View system information: Use
- Process management:
- View processes: Use
ps
the command, for exampleps aux
. - Kill a process: Use
kill
the command, for examplekill process_id
.
- View processes: Use
- Network management:
- View network interface information: Use
ifconfig
the command, for exampleifconfig
. - Test network connectivity: Use
ping
the command, for exampleping hostname
. - Remote connection: use
ssh
the command, for examplessh username@hostname
.
- View network interface information: Use
- Permissions and user management:
- Modify file permissions: use
chmod
the command, for examplechmod 755 filename
. - Modify file owner: use
chown
command, for examplechown username filename
. - To add a new user: use
useradd
the command, for examplesudo useradd username
. - To delete a user: use
userdel
the command, for examplesudo userdel username
.
- Modify file permissions: use
- Command line editor:
- Using the nano editor: Use
nano
the command, for examplenano filename
. - Using the vim editor: use
vim
the command, for examplevim filename
.
- Using the nano editor: Use
- Script writing and execution:
- Create a script file: Use a text editor to create a new file and add the script content.
- Execute a script file: use
bash
the command, for examplebash scriptname.sh
.