Basic Linux Skills
Written on August 3, 2021
I was helping someone pick up on basic Linux commands and thought it might be useful for others. Here are a bunch of things you can learn to get started with Linux terminal commands.
Directory commands
- Get the current directory
- Go up by one directory
- Go to home directory
- Go to previous directory
File commands
- Show names of all files and directories
- Show detailed list of files and directories
- Show detailed list but list but last modified time
- Show detailed list with file size in Kb and Mb instead of bytes
- Show files with extension .txt
Finding files
Find all files starting at current directory having the extension .txt
Displaying content
- Print contents of a text file
- Find lines containing the word ERROR in a file “log.txt”
- Find lines containing the word ERROR in a case insensitive manner “log.txt”
- Find lines that don’t contain the word ERROR in a case insensitive manner “log.txt”
- Repeat 2-4 for all .txt files in current folder.
- Repeat 2-4 for all .txt files in current and all sub-folders.
Displaying contents of a .gz file
- Print contents of a compressed text file “log.txt.gz”
- Repeat 2-6 from above
Displaying selected text
- Print the first few lines of a file
- Print the last few lines of a file
- Print first 10 lines of a file
- Print new lines being appended to a log file like apache access log
File Ownership and Access
- Check file permissions - who is the owner and group owner
- Check file permissions - who can read, write and execute
- Change file permissions - remove read access to “others”
- Change owner and group for a file
- Make a .sh file executable
File copy
- Copy one file to another
- Copy all files in one directory to another directory
- Create a new directory
- Move one file to another name (ie rename a file)
- Move one file from one directory to another directory (simple move)
- Move one directory as another directory (ie rename a directory)
- Delete a file
- Delete an empty directory
- Delete a directory with files
Compressing / Uncompressing
- Compress a log.txt to a gz file
- Uncompress a .gz file
- Bundle a folder with tar and compress with gz
- Show output of uncompression before actually uncompressing
SSH
- SSH to a remote machine with user id and password
- SSH to a remote machine using ssh key
- Load your ssh key and login without password
- scp a file from local to remote
- scp a file from remote to local
FTP
- FTP to a machine with user name password
- Set remote directory
- Set local directory
- Copy a file from local to remote
- Copy a file from remote to local
- Copy a folder from local to remote
- Copy a folder from remote to local
System
- List current processes
- Kill a misbehaving process
- Identify disk usage
Give these a try and hope you are on your way for a better life on the terminal :-)