Debian Commands Flashcards
Where can you view a list of user groups
/etc/group
How do you add a user to an admin group
sudo usermod -aG [GROUP] [USER]
-a (append) is critical or will remove from other groups rather than just adding to a new
Find the current date
date
Find the current working directory
pwd
Current computer name
hostname
View directory contents Inc hidden files
ls -a
How do you sort results in reverse
sort -r
How do you output to a text file
(In to home directory for this example)
> ~/output.txt
How to output any potential errors only
(eg of command/script for error logging)
2> [path]
How you output to both screen and file
tee [output path]
Output and add to existing file
> > [path]
Refer to entire contents of current directory
./*
File permissions order
User, Group, Others
How do you find a binary’s location, manual and source
whereis [binary]
How do you find a binary in the PATH variable
which
What is the basic syntax for ‘find’
find [dir] [option] [string]
How do you view the last 10 lines of a text file
tail [path]
How do you view the first 20 lines of a text file.
What is the default number of lines
head -20 <path/file>
Default is 10
How do you number lines in a text file
nl [path]
How do you search for any/all occurrence of a word and replace it
sed s/word/replacement/g
leave out g for just first instance of word, or replace it with the numerical instance of word.
How to request a new IP on WLAN
dhclient [WI-FIDEVICE]
How to append a line of text into a file
echo “STRING”»_space; PATH
How do you check if a software package is available in the Deb repositories
apt search STRING
How to uninstall software Inc config files
sudo apt purge
How do you remove software dependencies that are no longer required
sudo apt autoremove STRING
How do you install software with Git
git clone [GITHUB URL]
What is the change owner command
chown [user] [file]
Command to change group of a file
chgrp GROUP FILE
How do you change file/dir permissions
chmod <1-7><1-7><1-7> [path]
View current default permissions mask
umask
How do you SUID bit
Enter a 4 before the regular permissions
Eg chmod 4664 over 664
How do you add the SGID bit
Enter a 2 before the regular permissions
Eg chmod 2664 over 664
How do you find a command for something when you don’t know what it’s called?
apropos
I.e apropos password
How to scp to a remote server
scp [dir] [USER@REMOTESERV]:[dir]
common cpio options
-I designates an archive file to use
-i copy in from an archive
-o copy out and create archive
-t create table of contents list
-v verbose
—no-absolute-filenames