General Flashcards
How would you replace the word linux with linux-KT in a file called samples.txt
sed ‘s/linux/linux-KT’ samples.txt
How to copy a directory and it’s sub directories to a new location?
cp -R /keith /cathy
What is sed use for matching?
Regular expressions
How would you use sed to replace the second occurrence of a word?
sed ‘s/linux/linux-KT/2’ samples.txt
How would you delete the last 3 characters of each line in a file using sed?
sed ‘s/…$//’ samples.txt
How would you string two commands together in sed?
Using the ;
Example:
sed -e ‘s/#.*//;/^$/d’ thegeekstuff.txt
What is sed used for?
Searching and replacing in text files?
How would you search for text in all files in directories and sub directories?
grep -RnisI *
Search for a string inside all files in the current directory
This is how I typically grep. -R recurse into subdirectories, -n show line numbers of matches, -i ignore case, -s suppress “doesn’t exist” and “can’t read” messages, -I ignore binary files (technically, process them as having no matches, important for showing inverted results with -v)
I have grep aliased to “grep –color=auto” as well, but that’s a matter of formatting not function.
Add to favourites | Report as malicious
How to get current directory?
pwd
What is linux cut command used for?
extract portion of text from a file by selecting columns.
What is dd used for in linux?
dd can be used to raw copy a uncounted disk to a file.
What command could I use to get disk io?
Iostat
When swing top on a server with a processor with 4 cores, if the lode average is 4.57, is their processes having to wait ?
Yes
What are the 3 load average times when using top?
Last min
5 min
15 min
In a linux terminal how would you clear the screen?
ctrl-l
How would you search for a package?
apt-cache search
How would you get a lists of all installed packages?
dpkg -l
What syntax would you use to do the following, execute the next command if the current command was successful?
&&
What syntax would you use to have the next command execute if the current command failed to execute?
||
How can you string two or more commands together?
ls ; ls
What command would you use to get PCI info?
lspci -T -V
What command would you use to get a list of hardware info?
lshw
How can you get the nap client to update again a ntp ?service
ntp date -s ntp.ubuntu.com
How would you upgrade a package in linux?
apt-get upgrade
How would you upgrade all software in linux ?
apt-get upgrade
How would you upgrade the linux distribution?
apt-get dist-upgrade
How would you remove a package and it’s config files from linux?
apt-get purge
How would you clean out files from local repositories ?
Clean
What is the location of the cache directories associated with the clean command?
/var/cache/apt/archives/ and /var/cache/apt/archives/partial/
Where is the repo sources for apt-get
/etc/apt/sources.list
How would you do a apt-get install and simulate the operations?
apt-get -s install
With apt-get how would you simulate actions?
Use the -s flag
How to change current user password
passwd
How to shutdown the Linux OS
shutdown now
How to reboot the Linux OX
reboot
How can we create a tar
tar cvzf archive_name dirname/